Skip to content

Instantly share code, notes, and snippets.

@v9n
Created September 12, 2012 18:36
Show Gist options
  • Save v9n/3708941 to your computer and use it in GitHub Desktop.
Save v9n/3708941 to your computer and use it in GitHub Desktop.
Kill a procees with pid getting on the fly via awk
#For example, we want to kill Netbeans
ps -ef | grep beans | awk ' $6 != "ttys000" {print$2;}' | xargs kill {}
#Or get the first line only (to aovid getting grep command itself)
ps -ef | grep beans | head -n 1 | awk ' {print$2}' | xargs kill {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment