Last active
April 12, 2016 07:31
-
-
Save jargnar/6f72f49b3fc86df0816f0aae21967806 to your computer and use it in GitHub Desktop.
Check if a command exists in linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ]; then | |
printf "Please specify the command to check for.\n" | |
printf "Example:\n" | |
printf "$ ./checkcmd.sh docker\n" | |
else | |
if sudo command -v $1 >/dev/null 2>&1; then | |
printf "Yay! $1 exists.\n" | |
else | |
printf "Noo! $1 is not available.\n" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment