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

Re: grepping in ps output

On Sat, 29 Apr 2000, Tamas TEVESZ wrote:

> On Sat, 29 Apr 2000, Paul van Empelen wrote:
>  > And not all processes use a /var/run/<file>.pid.  With the commands
>  > ps ax | grep process, you sometimes see the 'grep process' in the output. 
>  > That's not what I want.
> grep -v grep

Evi Nemeth had a good trick for dealing with  that situation using the
short test notation:

f'rinstance, you want to nuke every process owned by user:

kill -9 `ps aux | grep [u]ser | awk '{print $2}'`

... where the trick is obviously the square brackets around the first
letter in the username, testing for the existence of that letter in the
grep output. This prevents the grep from being killed off before the
command can complete.


How often I found where I should be going only by setting out for
somewhere else..
                                       -- R. Buckminster Fuller

Reply to: