Skip to content

Instantly share code, notes, and snippets.

@btcrooks
Last active December 6, 2015 05:55
Show Gist options
  • Save btcrooks/77a6d987f666b8c18d64 to your computer and use it in GitHub Desktop.
Save btcrooks/77a6d987f666b8c18d64 to your computer and use it in GitHub Desktop.
This script takes multiple arguments and checks if those commands exist.
#!/usr/bin/env bash
#
# @description: This script takes multiple commands as arguments
# and checks if those commands exist on the system.
# Tested on bash, zsh, & ksh.
#
declare -a programs=("$@")
for i in "${programs}"; then
declare current_program="{$i}"
if ! type "${current_program}" >/dev/null 2&>1; then
# Not installed
echo "${current_program} is not installed on this machine."
else
# Installed
echo "${current_program} is installed -> $(which ${current_program})"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment