Skip to content

Instantly share code, notes, and snippets.

@davidraedev
Created December 3, 2017 23:25
Show Gist options
  • Save davidraedev/56ed12c8be146d0dc5d258d4086fa3e2 to your computer and use it in GitHub Desktop.
Save davidraedev/56ed12c8be146d0dc5d258d4086fa3e2 to your computer and use it in GitHub Desktop.
pidof implementation for Mac / OSX / MacOS
function pidof() {
if [ -z "$1" ]; then
echo 'pidof PROCESS';
return 1;
fi;
ps aux | grep -v grep | grep "$1" | awk '{print $2}';
}
@jasonm23
Copy link

jasonm23 commented Jun 3, 2024

Or just

brew install pidof

@davidraedev
Copy link
Author

True! Although if you're on a system that doesn't have homebrew this will work in a pinch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment