[WBEL-users] Another Shell Scripting Question

Purcocks, Graham grahamp at wsieurope.com
Wed Jun 15 10:28:28 CDT 2005


I use
 
ps -ef | awk '{print $2}' to get the pid
 
kill -9 `ps -efw | awk '{print $2}'`
 
would do it.
 
or ps aux | awk '{print $2}' if you want to use aux.
 
Graham

________________________________

From: whitebox-users-bounces at beau.org
[mailto:whitebox-users-bounces at beau.org] On Behalf Of Andrew Vong
Sent: 15 June 2005 15:56
To: whitebox-users at beau.org
Subject: [WBEL-users] Another Shell Scripting Question



Dear Gurus,

Thanks for all who responded to my previous question. It worked great! 

I am now trying to perform a "ps aux | grep "some regular expression" |
cut -f 2 -d ......"

I seem to be having 2 problems. 

1) What delimiter should I define for cut? I've tried " " (space) but
that does not work.
2) I usually get 2 processes listed. The actualy one I'm looking for and
the line I just executed. How can I exclude the 2nd process which also
contains the same "grep regular expression" ?

The above is part of a longer one-liner command I'm trying to construct.
I basically want to kill a specific process and I just want to obtain
the PID for it. So, it may end up looking like this??

$ ps aux | grep "some regular expression" | cut -f 2 -d ...... | xargs
kill -9

Or something along those lines... 

Hope someone out there can help me. 

Thanks again. :)

Best Regards,
Andrew


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://beau.org/pipermail/whitebox-users/attachments/20050615/d533dfa9/attachment-0001.htm


More information about the Whitebox-users mailing list