I know use ps -ef | grep test| grep -v grep |wc -l
ps -ef | grep test| grep -v grep |wc -l
ps -ef | grep test| grep -v grep |wc -l
can list the num of process test,and now i plan to list the test processes belong to user : forme .is this right as below : ps -ef | grep test|grep -x forme| grep -v grep |wc -l
ps -ef | grep test|grep -x forme| grep -v grep |wc -l
For a start, grep test| grep -v grep
grep test| grep -v grep
can be replaced with grep '[t]est'
. See here for an explanation.
Secondly, if you want to limit the processes to a single user, that's what the -u
option to ps
is for:
ps -fu forme | grep '[t]est' | wc -l
And, finally, grep
already has a -c
option to count lines, so you can ditch the wc
part of the pipeline:
ps -fu forme | grep -c '[t]est'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.