APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

which, whence


© November 2003 Tony Lawrence
2003/11/12

Search PATH for a program:

$ which ls
/bin/ls
 
The original Bourne shell (sh) had no command like which. The csh introduced "which". Ksh uses "whence", and bash etc. will use "which".

If the thing being searched for is a shell builtin like "cd", "which" and "whence" won't find it, but how that is reported can be very different:

( ksh on SCO OSR5 )
$ whence cd
cd
( bash on Mac OS X)
$ which cd
no cd in /bin /sbin /usr/bin /usr/sbin /Users/apl/bin /usr/local/bin /Developer/Tools
( tcsh on Mac OS X)
% which cd
cd: shell built-in command.
 

You may also have a "whereis" command, though this usually only searches the "standard" directories: it probably won't look anywhere you might have added to your PATH.

On OSR5 and some other POSIX compliant platforms, /bin/cd and other common shell builtins exist, so you must call the actual binary if that's what you need.

Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> which, whence

1 comment


Inexpensive and informative Apple related e-books:

iOS 8: A Take Control Crash Course

Take Control of the Mac Command Line with Terminal, Second Edition

Take Control of iCloud

Digital Sharing Crash Course

Take Control of Numbers




More Articles by © Tony Lawrence


On OSR5, whence can be given multiple args:

$ whence ls getty marry
/bin/ls
/etc/getty
/etc/marry

--BigDumbDinosaur



------------------------


Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us


Printer Friendly Version





There are two major products that came out of Berkeley: LSD and UNIX. We do not believe this to be a coincidence. (Jeremy S. Anderson)




Linux posts

Troubleshooting posts


This post tagged:

Shell

UnixWords



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode





SCO Unix Sales, Support, & Service

Phone:  707-SCO-UNIX (707-726-8649Toll Free: 833-SCO-UNIX (833-726-8649)
www.SCOsales.com