Command that Verify that a software is installed on Ubuntu

1

Script that checks whether software is installed on Ubuntu. If you have installed it continues with the command sequence. if you do not ask if the user wants to install anyway

Example:

if (programa1=Instalado, programa2=instalado); then  
continua script;  
else  
echo "Voce precisa do programa1 e ele não está instalado, deseja continuar  
 assim mesmo?"  
"sim"  
continua script  
"não"  
Sai do script  

I know that for DEB you can do this, used the control but would like to use a script.

    
asked by anonymous 26.04.2018 / 21:55

1 answer

2

Use the command command informing the argument -v

echo $(command -v git)

In the above example, if git was found it will have a similar return as below:

>> /usr/bin/git

otherwise, it will return nothing.

>> 

Checking the return:

if ! [ -x "$(command -v git)" ]; then
    echo 'git não instalado.' >&2
    exit 1
else
    echo 'git instalado.'
fi

See working on tutorialspoint.com

  

Remember that it works on all systems that use as a shell.

Reference

27.04.2018 / 00:15