[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: kill with regex?



On Sun, 19 Jan 2003, Antonio Rodriguez wrote:

> How would you produce this list?
> 
> Jor-el wrote:
> 
> >On Sun, 19 Jan 2003, Colin Watson wrote:
> >
> >  
> >
> >>On Sun, Jan 19, 2003 at 05:32:19PM +0100, Philipp Gruemmer wrote:
> >>    
> >>
> >>>Hugh Saunders wrote:
> >>>      
> >>>
> >>>>ps x gives a list of xine's which i would like to kill
> >>>>        
> >>>>
> >>>[...snip...]
> >>>      
> >>>
> >>>>2) how do i get kill or bash to realise its an expression?
> >>>>        
> >>>>
> >>>Is there any reason not to use 'killall xine'?
> >>>That's how I do it ususally...
> >>>      
> >>>
> >>'pkill xine' is better if you have a new enough version of procps, since
> >>'killall' does ... let's say surprising things on System V-ish variants
> >>of Unix.
> >>
> >>    
> >>
> >Hi,
> >
> >	A more general solution would be :
> >
> >	<produce list of pids to kill> | xargs kill
> >
Antonio,

	ps x | grep xine | awk '{print $1}'

	...would work for the original poster. So would killall, but
killall would work only when the process names are all the same. If, for
instance, you wanted to kill all processes belonging to a particular user,
one would do :
	
	ps auxw | awk '{if($1 == <username>) print $2}' | xargs kill

	(where <username> stands for the username that you are targetting)

Regards,
Jor-el



Reply to: