Check if an apt-get package is installed and then install it if it's not on Linux

后端 未结 22 1348
轮回少年
轮回少年 2020-12-02 04:02

I\'m working on a Ubuntu system and currently this is what I\'m doing:

if ! which command > /dev/null; then
   echo -e \"Command not found! Install? (y/n)         


        
22条回答
  •  生来不讨喜
    2020-12-02 04:10

    This seems to work pretty well.

    $ sudo dpkg-query -l | grep  | wc -l
    
    • It either returns 0 if not installed or some number > 0 if installed.

提交回复
热议问题