Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active September 23, 2020 00:28
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 miguelmota/8fc68cfb6ae5148f9772d2dde8b70d04 to your computer and use it in GitHub Desktop.
Save miguelmota/8fc68cfb6ae5148f9772d2dde8b70d04 to your computer and use it in GitHub Desktop.
Bash check if command exists example
# check that "vim" command exists
if ! command -v vim >/dev/null 2>&1; then
echo "vim not found"
exit 1
fi
# 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