up vote 3 down vote favorite
1
share [g+] share [fb]

Is there a command I can use to easily find the path to an executable? I'm looking for identify on my local machine - something like pwd?

pwd identify
=> /usr/local/bin/identify
link|improve this question
feedback

3 Answers

up vote 15 down vote accepted

which will search your path for the arguments you supply, it's found on just about any BSD or SysV UNIX

moriarty:~ dave$ which bash true false
/bin/bash
/usr/bin/true
/usr/bin/false
link|improve this answer
feedback

try 'locate identify'

link|improve this answer
3  
This works when "which" won't because the executable is not in your current PATH, but also tends to spew a lot of stuff you don't want. First path filter: "locate command | grep bin". Use "which" first. – dmckee Jun 12 '09 at 14:32
that's a good call, thanks. – Chopper3 Jun 12 '09 at 14:40
feedback

If you use the bash builtin type, it will show you all the (in-path) locations for a command:

$ type -a ls
ls is aliased to `ls --color=always'
ls is /bin/ls

$ type -a printf
printf is a shell builtin
printf is /usr/bin/printf

$ type -a touch
touch is /usr/bin/touch
touch is /bin/touch

If the command is a function, it will list the function definition:

$ type -a somefunc
somefunc is a function
somefunc ()
{
    echo "hello, world"
}

These examples are from a Ubuntu system, but the results will be similar for OS X.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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