Skip to content

Instantly share code, notes, and snippets.

@kanonji
Created October 23, 2012 13:30
Show Gist options
  • Save kanonji/3938742 to your computer and use it in GitHub Desktop.
Save kanonji/3938742 to your computer and use it in GitHub Desktop.
シェルスクリプトでコマンドの有無を判別する。
#!/bin/sh
echo "Finding $1..."
# if whereis $1 >/dev/null 2>&1; then 判別出来ない。
# if type $1 >/dev/null 2>&1; then 判別出来る。
# if which $1 >/dev/null 2>&1; then 判別出来る。
if which $1 >/dev/null 2>&1; then
echo "$1 found."
else
echo "$1 not found."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment