When you want to check if some tool you start from the command line is installed the following line would work:
if [ "`which someCommand`" = "" ]
The which
command checks for the full file name of the executable of someCommand
and if the file is not found the body of the if
statement is executed.
However this assumes that someCommand
is a command you can start from the command line (terminal etc.).
In your case you probably want to check if the file /usr/share/perl5/getopts.pl
exists.
According to this question this can be done using the following check:
if [ ! -f /usr/share/perl5/getopts.pl ]
This statement will check if some file not exist...
sudo
usually asks for a password. Do you supply one? Whichgetopts
do you want to install?libperl4-corelibs-perl
contains Perl 4 libraries which is approximately 25 years old. – PerlDuck Mar 11 '18 at 12:51apt-get install PACKAGE
? This will do exactly what the title says: Check if PACKAGE is installed, if not install it, else do nothing. – dessert Mar 11 '18 at 12:55