<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2627" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=863492919-15062005><FONT face=Arial 
color=#0000ff size=2>The answer is 'yes'. It will kill all processes which match 
your grep.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=863492919-15062005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=863492919-15062005><FONT face=Arial 
color=#0000ff size=2>ie kill&nbsp;n1 n2 n3 n4</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=863492919-15062005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=863492919-15062005><FONT face=Arial 
color=#0000ff size=2>will kill all 4 processes</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Andrew Vong 
[mailto:andrewvong@finpress.com] <BR><B>Sent:</B> 15 June 2005 
19:18<BR><B>To:</B> Will McDonald; Purcocks, Graham; whitebox-users@beau.org; 
John Haxby; Vincent Raffensberger<BR><B>Subject:</B> RE: [WBEL-users] Another 
Shell Scripting Question<BR></FONT><BR></DIV>
<DIV></DIV><BR>Dear Gurus,<BR><BR>A BIG thank you to all for your contributions. 
I have learnt from ALL your examples. <BR><BR>Here is what I have ended up 
with:- <BR><BR><FONT color=#0000ff>ps x | grep "[s]sh -f -N" | awk '{ print $1 
}' | xargs kill -p<BR><BR></FONT>I suppose this would work great if there were 
only 1 process as a result of the cmd above. <BR><BR>What would happen if there 
were more than 1 PID from std output? <BR><BR>Will it kill ALL PIDs that were 
produced from std output?<BR><BR>Thanks again. :)<BR><BR>Best 
Regards,<BR>Andrew<BR><BR><BR>At 11:28 PM 15/06/2005, Purcocks, Graham 
wrote:<BR>
<BLOCKQUOTE class=cite cite="" type="cite"><FONT face=arial color=#0000ff 
  size=2>I use<BR></FONT>&nbsp;<BR><FONT face=arial color=#0000ff size=2>ps -ef 
  | awk '{print $2}' to get the pid<BR></FONT>&nbsp;<BR><FONT face=arial 
  color=#0000ff size=2>kill -9 `ps -efw | awk '{print 
  $2}'`<BR></FONT>&nbsp;<BR><FONT face=arial color=#0000ff size=2>would do 
  it.<BR></FONT>&nbsp;<BR><FONT face=arial color=#0000ff size=2>or ps aux | awk 
  '{print $2}' if you want to use aux.<BR></FONT>&nbsp;<BR><FONT face=arial 
  color=#0000ff size=2>Graham</FONT><BR>
  <HR>
  <FONT face=tahoma size=2><B>From:</B> whitebox-users-bounces@beau.org [<A 
  href="mailto:whitebox-users-bounces@beau.org" 
  eudora="autourl">mailto:whitebox-users-bounces@beau.org</A>] <B>On Behalf Of 
  </B>Andrew Vong<BR><B>Sent:</B> 15 June 2005 15:56<BR><B>To:</B> 
  whitebox-users@beau.org<BR><B>Subject:</B> [WBEL-users] Another Shell 
  Scripting Question<BR></FONT><BR><BR>Dear Gurus,<BR><BR>Thanks for all who 
  responded to my previous question. It worked great! <BR><BR>I am now trying to 
  perform a "ps aux | grep "some regular expression" | cut -f 2 -d 
  ......"<BR><BR>I seem to be having 2 problems. <BR><BR>1) What delimiter 
  should I define for cut? I've tried " " (space) but that does not work.<BR>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 <I>regular expression</I>" ?<BR><BR>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??<BR><BR>$ ps aux | grep "some regular expression" | cut -f 2 -d 
  ...... | xargs kill -9<BR><BR>Or something along those lines... <BR><BR>Hope 
  someone out there can help me. <BR><BR>Thanks again. :)<BR><BR>Best 
  Regards,<BR>Andrew<BR></BLOCKQUOTE><BR>At 11:45 PM 15/06/2005, John Haxby 
wrote:<BR>
<BLOCKQUOTE class=cite cite="" type="cite">Andrew Vong wrote:<BR><BR><BR>
  <BLOCKQUOTE class=cite cite="" type="cite">Dear Gurus,<BR><BR>Thanks for all 
    who responded to my previous question. It worked great!<BR><BR>I am now 
    trying to perform a "ps aux | grep "some regular expression" | cut -f 2 -d 
    ......"<BR><BR>I seem to be having 2 problems.<BR><BR>1) What delimiter 
    should I define for cut? I've tried " " (space) but that does not 
  work.</BLOCKQUOTE><BR>cut -c might be better, or <FONT color=#ff0000>"awk 
  '{print $N}' </FONT>where "N" is the number of the column you want.<BR><BR>If 
  you're killing stuff, perhaps "killall" is what you want.<BR><BR>
  <BLOCKQUOTE class=cite cite="" type="cite">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/" ?</BLOCKQUOTE><FONT color=#ff0000>ps -ef | grep 
  "f\\oo"<BR><BR></FONT>works 
  nicely.<BR><BR>_______________________________________________<BR>Whitebox-users 
  mailing list<BR>Whitebox-users@beau.org<BR><A 
  href="http://beau.org/mailman/listinfo/whitebox-users" 
  eudora="autourl">http://beau.org/mailman/listinfo/whitebox-users</A><BR><BR></BLOCKQUOTE><BR>At 
12:41 AM 16/06/2005, Vincent Raffensberger wrote:<BR>
<BLOCKQUOTE class=cite cite="" type="cite"><FONT face=arial color=#0000ff 
  size=2>'pgrep' will give you the pid:<BR></FONT>&nbsp;<BR><FONT face=arial 
  color=#0000ff size=2>$ pgrep ntpd<BR>2106<BR></FONT>&nbsp;<BR><FONT face=arial 
  color=#0000ff size=2>'pkill' could kill it for you.&nbsp; See the 
  manpage.<BR></FONT>&nbsp;<BR><FONT face=arial color=#0000ff size=2>If you want 
  specific ps info for a process, you could ask for it along with the fields you 
  want instead of using cut or awk.<BR>See the manpage for all the different 
  fields you can select.&nbsp; Here's an example:<BR></FONT>&nbsp;<BR><FONT 
  face=arial color=#0000ff size=2>$ ps -p `pgrep ntpd` -o 
  pcpu,pmem,start,pid,cmd<BR>%CPU %MEM&nbsp; STARTED&nbsp;&nbsp; PID 
  CMD<BR>&nbsp;0.0&nbsp; 0.2&nbsp;&nbsp; Jun 13&nbsp; 2106 ntpd -N -b -g -u 
  ntp:ntp -p /var/run/ntpd.pid<BR></FONT>&nbsp;<BR><FONT face=arial 
  color=#0000ff size=2>If you must grep the full ps output, you can omit the 
  grep process like this:<BR></FONT>&nbsp;<BR><FONT face=arial color=#0000ff 
  size=2>$ ps aux | grep [n]tp<BR>ntp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  2106&nbsp; 0.0&nbsp; 0.2&nbsp; 5052 5052 
  ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SLs&nbsp; Jun13&nbsp;&nbsp; 0:01 
  ntpd -N -b -g -u ntp:ntp<BR></FONT><BR>
  <HR>
  <FONT face=tahoma size=2><B>From:</B> whitebox-users-bounces@beau.org [<A 
  href="mailto:whitebox-users-bounces@beau.org" 
  eudora="autourl">mailto:whitebox-users-bounces@beau.org</A>] <B>On Behalf Of 
  </B>Andrew Vong<BR><B>Sent:</B> Wednesday, June 15, 2005 9:56 AM<BR><B>To:</B> 
  whitebox-users@beau.org<BR><B>Subject:</B> [WBEL-users] Another Shell 
  Scripting Question<BR></FONT><BR><BR>Dear Gurus,<BR><BR>Thanks for all who 
  responded to my previous question. It worked great! <BR><BR>I am now trying to 
  perform a "ps aux | grep "some regular expression" | cut -f 2 -d 
  ......"<BR><BR>I seem to be having 2 problems. <BR><BR>1) What delimiter 
  should I define for cut? I've tried " " (space) but that does not work.<BR>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 <I>regular expression</I>" ?<BR><BR>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??<BR><BR>$ ps aux | grep "some regular expression" | cut -f 2 -d 
  ...... | xargs kill -9<BR><BR>Or something along those lines... <BR><BR>Hope 
  someone out there can help me. <BR><BR>Thanks again. :)<BR><BR>Best 
  Regards,<BR>Andrew<BR></BLOCKQUOTE></BODY></HTML>