how to find only PID value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to find only PID value
# 1  
Old 06-20-2008
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  
Old 06-20-2008
please have a try to this,
ps -ef | grep <value> | awk -F" " '{print $2}'
# 3  
Old 06-20-2008
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
# 4  
Old 06-20-2008
try:
Code:
ps -aef | grep -v grep | grep 'aaa.exe' | awk '{print $2}'

also check if the pgrep command is useful for you
# 5  
Old 06-20-2008
Hi,

You can try with this command

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

Regards,
SPSmilie
# 6  
Old 06-20-2008
Quote:
Originally Posted by Yogesh Sawant
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
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find the corresponding command for a existing PID?

Hi All, A process completed already and I have the PID. I want to know the which command used for this PID. 'ps' command and '/proc' folder having the list current process only. Is there a way to search completed process PID? Thanks, Manimuthu (5 Replies)
Discussion started by: k_manimuthu
5 Replies

2. UNIX for Advanced & Expert Users

Find PID using a Port?

Hi, I do not have root user credentials nor do I have the functional id of the process that uses port 80. How can I find the pid of the process using the port number 80 ? Operating System: Linux (6 Replies)
Discussion started by: mohtashims
6 Replies

3. HP-UX

Find port for Pid

Hi, Is this the most appropriate way of finding the listen port number given the pid is "16659" ? lsof -Pan -i tcp -i udp | grep 16659 | grep -i "listen"If so, how can I extract "7001" and assign it to a variable say myport=7001 from the below output which happens to be actual port number? ... (1 Reply)
Discussion started by: mohtashims
1 Replies

4. UNIX for Dummies Questions & Answers

Find PID for a port

Hi, I need to find the PID for a given port on the below system. HP-UX mymachine B.11.31 U ia64 3223107173 unlimited-user license How can I ? (4 Replies)
Discussion started by: mohtashims
4 Replies

5. Shell Programming and Scripting

Find PID for a process

I want to kill a process run by a user of another group. How do I do that..? (3 Replies)
Discussion started by: Haimanti
3 Replies

6. Solaris

how to find PID of a runnign process ?

Hi Friends, How can we find the process ID of a running process using the process name. In AIX I used to use the command "ps -ef | grep <process name>", it used to give me the owner of that process, Process ID and the threads running and the name of the process in the end. However in... (2 Replies)
Discussion started by: sahilsardana
2 Replies

7. Shell Programming and Scripting

KSH 88 - Can I find the PID for an IP connection?

Hi, If I use this command netstat | grep "1268" it shows me all IP addresses connected via port 1268, which is half of what I want. I would like to be able to then map these against a PID on the system, and also thereby get the userid. I have done a couple of days google bashing but... (3 Replies)
Discussion started by: gcraill
3 Replies

8. UNIX for Advanced & Expert Users

Find PID's

I have a script which spawns multiple compilations. Sometimes due to some errors i have to terminate that script. Now comes the main part, how do I do that? I can see the individual compilations via ps -ef | grep compiler and also kill them via kill -9 pid But the scirpt continues: ... (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies

9. UNIX for Dummies Questions & Answers

How to find a hanging pid

I am trying to write a simple shell script to find a hanging pid and kill it.Any idea how to find a hanging pid?? (6 Replies)
Discussion started by: Ravi Kanth
6 Replies
Login or Register to Ask a Question