Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if there is a built-in command in Bash (or even something OSX-specific) that would display the fully resolved path of a script that is in the current PATH environment variable.

For example, my PATH currently looks like this:

>: echo $PATH | tr ":" "\n"

And there's a script in Dropbox called That path is in my PATH variable for convenience, but if I wanted to display the complete path to that script, assuming I wasn't sure where it was, is there an simple one-liner way to display the fully resolved path instead of testing it at each of the directories above?

share|improve this question
up vote 5 down vote accepted

You can use which. From the man page:

The which utility takes a list of command names and searches the path for each executable file that would be run had these commands actually been invoked

share|improve this answer
Boom. I knew there had to be something. Will accept the answer as soon as the mandatory waiting period is up. Thanks! – Josh Jun 24 '14 at 19:16
whoops, didn't see your answer initially. cheers! – njboot Jun 24 '14 at 19:18
which -a [nameofexecutable]


Macbook-Pro:~ njboot$ which -a chmod 
Macbook-Pro:~ njboot$ which -a nusers
share|improve this answer

A good alternative to which is the builtin type. The advantage being that type is also able to handle bash aliases and functions.

share|improve this answer
There's also type -P which restricts itself to executables on disk only - no aliases are shown. – Rich Homolka Jun 24 '14 at 22:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.