Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Last active December 30, 2015 17:09
Show Gist options
  • Select an option

  • Save glenjamin/7859662 to your computer and use it in GitHub Desktop.

Select an option

Save glenjamin/7859662 to your computer and use it in GitHub Desktop.
Portable shell function to neatly wrap the pgrep/pkill combo
# 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