Friday, August 10, 2012

Wild Kill...Yeee-Haaah!!!

#!/bin/bash
ps -ef | grep $1 | awk '{print $2}' | while read pid; do kill -15 $pid; done

Save the script as wildkill.sh, make it executable:

chmod 755 wildkill.sh

and run it like this:

./wildkill.sh firefox

This will kill any process that contains the name firefox...be sure you know what you're killing because this script can be wild!

Yeee-Haaah!


3 comments:

  1. I love what goes on in that crazy head of your sometimes ;) Craaazzzy Jake!!

    ReplyDelete
  2. Cool script ;) How about you extend it to have it randomly choose binaries from /usr/bin and /usr/sbin and pass that as an argument to grep (instead of $1 - your script argument). Name that one something like, oh I dont't know...goinPostal.sh..?

    ReplyDelete
  3. I can hear the black unmarked roflcopters flying above :)

    I've always been a fan of these:

    :() { :|: }; :

    OR

    sudo kill -9 -1

    We could call the first one fork_urself.sh and the next one junk_punch.sh...I like it. :)

    ReplyDelete