Running Ubuntu 16.04 I want to install (programmatically) getopts if it is not installed.
After this post I am doing something like this:
GETOPTS=getopts
if [$GETOPTS==""]
then
echo "Installing getopts"
sudo apt-get install -y libperl4-corelibs-perl
fi
But it is not working.
Any Idea how to do this?
When you want to check if some tool you start from the command line is installed the following line would work:
The
which
command checks for the full file name of the executable ofsomeCommand
and if the file is not found the body of theif
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:
This statement will check if some file not exist...