How can I find the path to an executable in OSX

Solution 1:

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

Solution 2:

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.


Solution 3:

try 'locate identify'