Super User is a question and answer site for computer enthusiasts and power users. 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 need to know the path of Spotlight knows where to find .apps, so there is a system on MacOS to find such things. Is there a command line tool that would provide this information e.g.:

$ tool Xcode
share|improve this question
up vote 7 down vote accepted

Access the Spotlight database from the command line, searching for applications named "Xcode":

mdfind "kMDItemDisplayName==Xcode&&kMDItemKind==Application"

To view the Spotlight metadata for a given file or folder, use mdls, e.g. mdls /Developer/Applications/

Alternatively, you can use AppleScript to get the path if Xcode is running.

tell application "System Events"
    tell application process "Xcode"
        set a to application file
        POSIX path of a
    end tell
end tell
share|improve this answer
POSIX path of (path to app "Xcode") would be faster than System Events and work even if the app is not open. – user495470 Feb 16 '12 at 21:17
@Lri Thanks, I knew this was possible, but didn't find it. – Daniel Beck Feb 16 '12 at 21:21

try this:

sudo find / -name 'Xcode'

you can also use regex in the name of the thing you're looking for if you're using quotes.

share|improve this answer
The name is Additionally, this takes forever. – Daniel Beck Feb 16 '12 at 18:04

If the app is somewhere on your path, you can use 'type':

jrobert$ type g++
g++ is /usr/bin/g++

Otherwise you'll need to use 'find' (or one of the several OS-X file-finders).

share|improve this answer
Mac OS X graphical applications are not usually on the $PATH. – Daniel Beck Feb 16 '12 at 18:04
Not the .apps, no, but since the OP uses Xode in his example, it's worth mention for finding the accomanying command-line development tools. – JRobert Feb 16 '12 at 18:09

You must log in to answer this question.

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