Skip to content

Instantly share code, notes, and snippets.

@raspberrypisig
Last active April 29, 2020 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raspberrypisig/2fe63119def22c7fb7f054ae511de375 to your computer and use it in GitHub Desktop.
Save raspberrypisig/2fe63119def22c7fb7f054ae511de375 to your computer and use it in GitHub Desktop.
command_installed() {
type -ap $1 >/dev/null 2>/dev/null
}
command_to_test="ls"
command_installed $command_to_test
if [ "$?" -eq "0" ];
then
echo Command $command_to_test is installed.
else
echo Command $command_to_test is not installed.
fi
command_to_test="lsaaaaaa"
command_installed $command_to_test
if [ "$?" -eq "0" ];
then
echo Command $command_to_test is installed.
else
echo Command $command_to_test is not installed.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment