7 ms·
I have this little bash function which I like to use to find out if a program is running, and to optionally kill it. Originally my goal was to keep it fitting i
by glenjamin 10y ago
I have this little bash function which I like to use to find out if a program is running, and to optionally kill it. Originally my goal was to keep it fitting inside a tweet, but adding helpful messaging just pushed it over.
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 $*
}