How Do I Programmatically Check for a Program's Existence? How Do I Programmatically Check for a Program's Existence? unix unix

How Do I Programmatically Check for a Program's Existence?


If you are using bash, you can use the type builtin:

$ type -f svnsvn is /usr/bin/svn

If you want to use it in a script:

$ type -f svn &>/dev/null; echo $?0$ type -f svn_doesnt_exist &>/dev/null; echo $?1


Try to actually call it.

It makes most sense to call it with -V or whatever else option that makes the program report its version; most of the time you want the program to be at least such-and-such version.

If your program is a shell script, which is your friend, too.