[lug] Regex from shell

Hugh Brown hugh at math.byu.edu
Thu Dec 30 19:47:01 MST 2004


On Sat, 2004-11-20 at 16:20 -0700, David Morris wrote:
> On Fri, Nov 19, 2004 at 01:41:47PM -0800, Budyanto Himawan wrote:
> > Hey...thanks a lot.
> > 
> > This was what I was looking for
> > kill 111{0,1,2,3,4,5,6,7,8,9}.
> > 
> > But this
> > kill $( seq 1110 1119 ) is a whole lot more elegant.:)
> 
> If you want to kill a large number of processes that aren't
> in a nice pattern and killall/pkill don't quite get what you
> want (which I seem to need constantly), try ps/grep/awk:
> 
>     kill `ps -afe | grep '<pattern>' | awk '{print $2}'`
> 
> --David

I'm kind of partial to (for no good reason):

ps -ef|grep <pattern>|cut -c 10-15|xargs kill

Humorously, I'm wearing my perl shirt that says "There's more than one
way to do it" :)

Hugh




More information about the LUG mailing list