Count the number of lines in a piped input?

0

While running

ps -eaf

I see a list of running processes.

Is it possible to count the number to lines using awk?

Whitewolf

Posted 2013-10-22T13:37:51.250

Reputation: 1

Answers

1

The best way to do it, in the sense of the simplest way to do it, is to issue the command:

ps -eaf | wc -l

The command wc was originally written to count words, but it can also count lines (that's the -l option), characters (-m), bytes (-c),... see man wc.

MariusMatutiae

Posted 2013-10-22T13:37:51.250

Reputation: 41 321

0

ps -eaf | awk '{ ++cnt } END { print cnt }'

sparkie

Posted 2013-10-22T13:37:51.250

Reputation: 2 110