I need to check the path to a program -- I want to point to the binary, not to the ".app" which is a directory. How do I do this?
Navigate to your
Applications folder, right click on any app, choose Show Package Contents and navigate to
Contents/MacOS/. Most of the times, the binary is named after the app so, if using the path on a script, you'll be mostly safe by using
(appname) is, well, the name of the app. If the app name has a whitespace in it, eg. Sublime Text, don't forget to put the path between double quotes (or escape it), in your script.
As @megadroid posted, Applications have executable in
Contents/MacOS directory. However executable name not necessarily is the same as app name. To get exact executable name, You can read it from Info.plist file (under
CFBundleExecutable key) or do it from Terminal.app with for example:
APP_PATH="/Applications/Mail.app" echo "$APP_PATH"/Contents/MacOS/$(defaults read "$APP_PATH/Contents/Info.plist" CFBundleExecutable)
APP_PATH variable. Result: