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 get-azurelogs.sh. 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?

3 Answers 3


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

  • 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, 2014 at 19:16
  • whoops, didn't see your answer initially. cheers!
    – njboot
    Jun 24, 2014 at 19:18

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

  • There's also type -P which restricts itself to executables on disk only - no aliases are shown. Jun 24, 2014 at 22:40
which -a [nameofexecutable]


Macbook-Pro:~ njboot$ which -a chmod 
Macbook-Pro:~ njboot$ which -a nusers

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .