Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Confusion with PS

$
0
0
Hello All,

I have a problem in counting number of process getting run with my current script name..

Here it is

Code:

ps -ef | grep $0 | grep -v grep
This display just one line with the PID, PPID and other details when i print it in the script.

But when I want to count the numbers in my script , just like below, it comes out as 2... Whereas only one process is running..

Code:

count=$(ps -ef | grep $0 | grep -v grep | wc -l)
echo $count

My mind completely gone blank, help me here..
Help me how I will get my script to print the correct number of Process running with its name. Thanks.

Viewing all articles
Browse latest Browse all 16232

Trending Articles