Last active
September 23, 2020 00:28
-
-
Save miguelmota/8fc68cfb6ae5148f9772d2dde8b70d04 to your computer and use it in GitHub Desktop.
Bash check if command exists example
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
# check that "vim" command exists | |
if ! command -v vim >/dev/null 2>&1; then | |
echo "vim not found" | |
exit 1 | |
fi |
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
# check that "realpath" command exists | |
if ! type "realpath" > /dev/null; then | |
printf "$red%s$normal$nc\n" "\"realpath\" command is not installed" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment