How to get pid given the process name
I think it is easier to use pgrep $ pgrep bluetoothd 441 Otherwise, you can use awk: ps -ef | awk ‘$8==”name_of_process” {print $2}’ For example, if ps -efhas a line like: root 441 1 0 10:02 ? 00:00:00 /usr/sbin/bluetoothd Then ps -ef | awk ‘$8==”/usr/sbin/bluetoothd” {print $2}’ returns 441. In ksh pgrep is not … Read more