Created
January 6, 2015 15:30
-
-
Save kkleidal/30f7c2a170445a261155 to your computer and use it in GitHub Desktop.
PID of Process BASH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get the PID of a process matching the pattern specified | |
# in the first argument as displayed in ps axf | |
# This line can be used in any script, just replace $1 with the match string: | |
PID=$(ps axf | grep "$1" | grep -v grep | awk '{print $1}' | head -n1) | |
echo "$PID" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment