Ubuntu – How to count number of process instances with bash

bashcommand linescripts

Writing

ps aux | awk '{print $11}'

Gives me all the process instances, but how do I count them, is there a command that does that?

Best Answer

As ps aux prints information about one process per line (including a headline, which can be disabled with the --no-heading option).

Therefore you can easily count the processes by simply counting the lines of this output, using wc:

ps aux --no-heading | wc -l