Skip to content

Instantly share code, notes, and snippets.

@samyranavela
Forked from gubatron/command_exists.sh
Created September 21, 2017 14:19
Show Gist options
  • Save samyranavela/8f87bccb6d7744c12b673d0585fb1606 to your computer and use it in GitHub Desktop.
Save samyranavela/8f87bccb6d7744c12b673d0585fb1606 to your computer and use it in GitHub Desktop.
check if command exists (linux, mac)
function command_exists {
#this should be a very portable way of checking if something is on the path
#usage: "if command_exists foo; then echo it exists; fi"
type "$1" &> /dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment