The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-29-2005
Registered User
 

Join Date: Aug 2005
Posts: 39
Question how to get PID only

The below command returns full line.How can i get only PID from this line ie 15794 from the below example

(FI NY) nbswpsa52.ny.ficc.gs.com~ ->ps -ef | grep keepalive | grep -v keepaliveStub | grep -v swapback | grep -v grep
ficctprd 15794 1 0 13:12:58 ? 0:01 keepalive
Reply With Quote
Forum Sponsor
  #2  
Old 08-29-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Continuing on your solution, try this.

Code:
ps -ef | grep keepalive | grep -v keepaliveStub | grep -v swapback | grep -v grep | awk '{ print $2 }'
Vino
Reply With Quote
  #3  
Old 08-29-2005
Registered User
 

Join Date: Aug 2005
Posts: 39
Thanks It worked
Reply With Quote
  #4  
Old 08-29-2005
Registered User
 

Join Date: Jul 2005
Posts: 33
try this. much simpler and to the point:
Code:
ps -eo comm,pid | awk '$1 == "keepalive" { print $2 }'

Last edited by hadarot; 08-31-2005 at 01:01 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0