determining if an executable is in the search path

In bash, how can one test whether an executable program is found in
the executable search path? Thanks.
Russ.Paielli [ Fr, 02 November 2007 19:32 ] [ ID #1860576 ]

Re: determining if an executable is in the search path

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
Stephane CHAZELAS [ Fr, 02 November 2007 19:50 ] [ ID #1860577 ]
Linux » comp.unix.shell » determining if an executable is in the search path

Vorheriges Thema: [bash] last element of the $* array
Nächstes Thema: Expect, How do I have different output for different prompts