Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to know the path of Xcode.app. 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

3 Answers 3

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/Xcode.app.

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. –  ؘؘؘؘ 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 Xcode.app. 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

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.