When I run ps -aef | grep aaa.exe it gives out put
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
please have a try to this,
ps -ef | grep <value> | awk -F" " '{print $2}'
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
try:
ps -aef | grep -v grep | grep 'aaa.exe' | awk '{print $2}'
also check if the pgrep command is useful for you
Hi,
You can try with this command
ps -ef | grep "/aaa.exe " | awk -F" " '{print $2}'
Regards,
SP:b:
Thanks Yogesh Sawant
Best use is pgrep ie ps -aef | grep aaa.exe