Let's say I run the following commands:
sleep 500
/bin/sleep 500
sleep 30
What I'm interested is, how to count the number of instances of the sleep program, with certain arguments (in this case the only argument is 500
).
So in the example above, if I count the number of instances of /bin/sleep 500
, it should return 2.
I tried this: pgrep -xfc '/bin/sleep 500'
, but since it exactly matched the argument in the parenthesis, sleep 500
isn't counted.
/proc
filesystem? That makes it easier to find the pathname of each process's executable. – Mark Plotnick May 25 '16 at 18:13