Last active
December 30, 2015 17:09
-
-
Save glenjamin/7859662 to your computer and use it in GitHub Desktop.
Portable shell function to neatly wrap the pgrep/pkill combo
This file contains hidden or 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
| # List processes via pgrep, then prompt to pkill | |
| pgk() { | |
| [ -z "$*" ] && echo 'Usage: pgk <pattern>' && return 1 | |
| pgrep -fl $* | |
| [ "$?" = "1" ] && echo 'No processes match' && return 1 | |
| echo 'Hit [Enter] to pkill, [Ctrl+C] to abort' | |
| read && pkill -f $* | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment