Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Last active January 2, 2016 19:29
Show Gist options
  • Select an option

  • Save coderofsalvation/8350368 to your computer and use it in GitHub Desktop.

Select an option

Save coderofsalvation/8350368 to your computer and use it in GitHub Desktop.
find and kill by brett terpstra
# find and kill by brett terpstra (saving repetitive ps aux + kill -9 )
fp () { #find and list processes matching a case-insensitive partial-match string
ps Ao pid,comm|awk '{match($0,/[^\/]+$/); print substr($0,RSTART,RLENGTH)": "$1}'|grep -i $1|grep -v grep
}
fk () { # build menu to kill process
IFS=$'\n'
PS3='Kill which process? '
select OPT in $(fp $1) "Cancel"; do
if [ $OPT != "Cancel" ]; then
kill $(echo $OPT|awk '{print $NF}')
fi
break
done
unset IFS
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment