determining if an executable is in the search path

determining if an executable is in the search path

am 02.11.2007 19:32:51 von Russ.Paielli

In bash, how can one test whether an executable program is found in
the executable search path? Thanks.

Re: determining if an executable is in the search path

am 02.11.2007 19:50:28 von Stephane CHAZELAS

2007-11-02, 18:32(-00), Russ P.:
> In bash, how can one test whether an executable program is found in
> the executable search path? Thanks.

if command -v cmd > /dev/null 2>&1; then
echo "there is a cmd command available"
fi

If you want to search for cmd in $PATH and not as a builtin or
function, you can use type -P instead of "command -v" but that's
bash specific.

--
Stéphane