News for hackers. Stuff that matters.
Re:A Unix Utility to Know About: lsof (2009) by glenjamin on Friday August 26, 2016 @10:17AM (#12366412)
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 $*
    }

There are no comments on this comment yet.