Skip to content

Instantly share code, notes, and snippets.

@yantonov
Last active October 14, 2015 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yantonov/4291698 to your computer and use it in GitHub Desktop.
Save yantonov/4291698 to your computer and use it in GitHub Desktop.
Get process id by name in linux.
##/bin/bash
# find process id by name
# returns pid
if [ $# -lt 1 ]; then
echo "Usage: pidbyname name"
exit 0
else
EXEC_NAME=$1
fi
ps -e | grep "bash" | awk -F\ '{print $1}'
# or use pgrep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment