never thought ppl would need this. Here's what I use:
ps| grep $LOGNAME | awk '{ if (index($0,"gvim") && index($8,"awk")==0) print
$2}'
ps - get processes
grep - remove other users' processes (just in case)
awk - very ineffecient usage, but works - just get the second column for
those rows where the process (gvim) in this case is running and not awk
pipe to kill :
ps| grep $LOGNAME | awk '{ if (index($0,"gvim") && index($8,"awk")==0) print
$2}' | xargs kill
while we are on it, here's one more to copy certain type of files to some
directory
find ./ -name *.ext | xargs -I {} cp {} <target dir>
Possible and required improvement
get details from command line rather than hard coding
ps| grep $LOGNAME | awk '{ if (index($0,"gvim") && index($8,"awk")==0) print
$2}' | xargs kill
Here are a few more I use:
2008/11/7 narendra sisodiya <[EMAIL PROTECTED]>
> This is a very simple try, please extend and republish it
>
> Task : killing process by "patten matching in ps -ef"
>
> $ vi kill_grep
>
> paste this
>
> #!/bin/bash
> kill -9 $(ps -ef | grep $1 | cut -c9-15 | head -n-1)
> exit 0
>
> chmod +x kill_grep
> cp kill_grep /bin
>
>
> now you can kill process by name itself,,
> like
>
> $ kill_grep gftp
>
> will kill all gftp instance ...
>
>
>
> -- released in public domain, please extend this to make it a good
> utility,,
>
> PS: this is made for new user or like me who want to type less or automate.
> not for command line Geeks.
> --
> ┌───[ Narendra Sisodiya ]──────────────┐
> │ http://narendra.techfandu.org
> │ http://www.lug-iitd.org
> └─new number ───[ +91-93121-66995 ]──────┘
>
> >
>
--
Lots o' Luv,
Phani Bhushan
Let not your sense of morals prevent you from doing what is right - Isaac
Asimov (Salvor Hardin in Foundation and Empire)
--~--~---------~--~----~------------~-------~--~----~
[EMAIL PROTECTED] mailing list -- group http://groups.google.com/group/iitdlug
-~----------~----~----~----~------~----~------~--~---