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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 6 10-25-2008 01:37 PM
Little bit weired : Find files in UNIX w/o using find or where command jatin.jain Shell Programming and Scripting 10 09-19-2007 07:47 AM
help to find find filename usingFile pointer in c arunkumar_mca UNIX for Dummies Questions & Answers 2 08-07-2007 11:23 AM
Find files older than 20 days & not use find halo98 Shell Programming and Scripting 2 05-18-2006 03:19 PM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 06:38 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-20-2008
madhusmita madhusmita is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
how to find only PID value

When I run ps -aef | grep aaa.exe it gives out put


Code:
user  5091  5518   0 10:13:25 pts/1       0:00 grep aaa.exe
user  4647  2479   0 09:26:31 ?           0:25 /kk/zzz/user/xxx/bin/aaa.exe
user1  1111  2222   0 08:26:31 ?           0:25 /kk/zzz/user1/xxx/bin/aaa.exe

I need Only PID value ie 4647,1111

So how can I run in the command prompt

Last edited by Yogesh Sawant; 06-20-2008 at 05:56 AM.. Reason: added code tags
  #2 (permalink)  
Old 06-20-2008
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
please have a try to this,
ps -ef | grep <value> | awk -F" " '{print $2}'
  #3 (permalink)  
Old 06-20-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
try:
Code:
ps -aef | grep -v grep | grep 'aaa.exe' | awk '{print $2}'

also check if the pgrep command is useful for you
  #4 (permalink)  
Old 06-20-2008
psiva_arul's Avatar
psiva_arul psiva_arul is offline
Registered User
  
 

Join Date: Jul 2007
Location: Bangalore, India
Posts: 97
Hi,

You can try with this command

ps -ef | grep "/aaa.exe " | awk -F" " '{print $2}'

Regards,
SP
  #5 (permalink)  
Old 06-20-2008
madhusmita madhusmita is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
Quote:
Originally Posted by Yogesh Sawant View Post
try:
Code:
ps -aef | grep -v grep | grep 'aaa.exe' | awk '{print $2}'

also check if the pgrep command is useful for you

Thanks Yogesh Sawant

Best use is pgrep ie ps -aef | grep aaa.exe
  #6 (permalink)  
Old 06-20-2008
madhusmita madhusmita is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
it displays PID value with PID of grep aaa.exe but I dont need PID value of grep aaa.exe and again When I stored it to a variable it stores all values ie PID,tty etc but I need only value to store in the variable without grep aaa.exe value ie only running aaa.exe value

Plz suggest
Closed Thread

Bookmarks

Tags
grep, pgrep

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0