Skip to content

Instantly share code, notes, and snippets.

@agebrock
Created June 27, 2013 03:10
Show Gist options
  • Save agebrock/5873670 to your computer and use it in GitHub Desktop.
Save agebrock/5873670 to your computer and use it in GitHub Desktop.
check for commands
my_needed_commands="sed awk lsof who"
missing_counter=0
for needed_command in $my_needed_commands; do
if ! hash "$needed_command" >/dev/null 2>&1; then
printf "Command not found in PATH: %s\n" "$needed_command" >&2
((missing_counter++))
fi
done
if ((missing_counter > 0)); then
printf "Minimum %d commands are missing in PATH, aborting\n" "$missing_counter" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment