how to test for named executable in path?

Jerry Peek jdpeek at RODAN.ACS.SYR.EDU
Sat May 27 14:42:08 AEST 1989


In article <43666082.bea3 at mach1.engin.umich.edu> brian at caen.engin.umich.edu (Brian Holtz) writes:
> Is there an elegant way to tell if a file is in your path?
> which(1), of course, tells you where a file is, and in a roundabout
> way tells you whether it's pathed; isn't there a clean way to
> find this out?

Well, you can just read the which program -- it's a shell script, on a lot of
systems anyhow.  Basically, it starts a "for" loop that steps through each
directory in the path.  In each directory, it tests for the specified
filename -- if the filename is executable AND is not a directory, then
the filename is "in the path".

--Jerry Peek; Syracuse University Academic Computing Services; Syracuse, NY
  jdpeek at rodan.acs.syr.edu, jdpeek at suvm.bitnet
  +1 315 443-3995



More information about the Comp.unix.questions mailing list