Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!RODAN.ACS.SYR.EDU!jdpeek From: jdpeek@RODAN.ACS.SYR.EDU (Jerry Peek) Newsgroups: comp.unix.questions Subject: Re: how to test for named executable in path? Keywords: which(1) Message-ID: <8905270342.AA12233@rodan.acs.syr.edu> Date: 27 May 89 04:42:08 GMT References: <43666082.bea3@mach1.engin.umich.edu> Sender: daemon@ucbvax.BERKELEY.EDU Organization: Syracuse University; Syracuse, New York Lines: 15 In article <43666082.bea3@mach1.engin.umich.edu> brian@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@rodan.acs.syr.edu, jdpeek@suvm.bitnet +1 315 443-3995