We have moved to a new Sailfish OS Forum. Please start new discussions there.
1

how to count specific process with cli? [answered]

asked 2017-04-28 15:56:03 +0300

cemoi71 gravatar image

updated 2017-04-28 16:22:37 +0300

Hello all,

i would like to count the number of process in terminal.
I don't know exactly how to do this.
After informing into internet, i may use the combination of ps with grep.

I tried:
ps -aux | grep process_name

And i get all the lines of process with the defined name.
Normally grep has the option -c to count the lines, but it doesn't work here. why?
With -n seems that i get the line number and the line. Do i have the info that i need?

There is no possibility to check command man-page? with man. nor alternative?

edit. commands which work:
ps aux | grep process_name | wc -l
ps aux | grep -c process_name
Should be no '-' before 'aux'

Could someone help me for this please?
Thank you very much in advance.

Cheers

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by cemoi71
close date 2017-04-28 16:22:59.121475

Comments

Option -cdoes work, I've just tested it... So we can't tell you why: ps aux | grep -c process_name

I think it's not the good place to learn general Linux stuff.

Sthocs ( 2017-04-28 16:12:35 +0300 )edit
1

yes i know. the problem that i had was that i get a reponse with ps -aux alone and ps -aux | grep process name, but at the moment i tried to put the option -c to grep i got an error .
then i thought that the cli in sfos would be a little bit different, that why i started here.
I remarked my error as the leszek give me his solution with ps aux (without '-' before)...

cemoi71 ( 2017-04-28 16:58:36 +0300 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2017-04-28 16:09:17 +0300

leszek gravatar image

updated 2017-04-28 16:10:34 +0300

Just pipe the command to wc -l to count.

So basically

ps aux | grep process_name | wc -l

As for help. Manpages aren't installed (for space reasons I guess). Usually commands have a --help parameter.

edit flag offensive delete publish link more

Comments

1

great! thank you very much.
i don't understand why ps don't need here the '-' character. seems that '-' is needed by other systems.
with ps aux | grep -c process_name works too...

cemoi71 ( 2017-04-28 16:19:48 +0300 )edit

Question tools

Follow
1 follower

Stats

Asked: 2017-04-28 15:56:03 +0300

Seen: 146 times

Last updated: Apr 28 '17