How to get the PID of a process by giving the process name in Mac OS X ? How to get the PID of a process by giving the process name in Mac OS X ? bash bash

How to get the PID of a process by giving the process name in Mac OS X ?


The answer above was mostly correct, just needed some tweaking for the different parameters in Mac OSX.

ps -A | grep [f]irefox | awk '{print $1}'


You can use the pgrep command like in the following example

$ pgrep Keychain\ Access44186


You can install pidof with Homebrew:

brew install pidofpidof <process_name>