<!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=524052816-15062005><FONT face=Arial 
color=#0000ff size=2>'pgrep' will give you the pid:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><FONT face=Arial 
color=#0000ff size=2>$ pgrep ntpd<BR>2106</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><FONT face=Arial 
color=#0000ff size=2>'pkill' could kill it for you.&nbsp; See the 
manpage.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><FONT face=Arial 
color=#0000ff size=2>See the manpage for all the different fields you can 
select.&nbsp; Here's an example:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><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</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><FONT face=Arial 
color=#0000ff size=2>If you must grep the&nbsp;full ps output, you can omit the 
grep process like this:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=524052816-15062005><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</FONT></SPAN></DIV><FONT 
face=Arial color=#0000ff size=2></FONT><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> whitebox-users-bounces@beau.org 
[mailto:whitebox-users-bounces@beau.org] <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></DIV>
<DIV></DIV><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><BR></BODY></HTML>