ps -e | grep -c '^'
Whatever it means I have 166
I got lost with the '^' and can't remember where I seen it
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
--count) option of
grep prints the number of matches.
^ is a regular expression metacharacter representing the beginning of a line (and does not match any actual character).
Your command shows the count of all processes, as seen by
Note that running the same command, removing the
-c option from
grep, should display the actual output your count is based on.
^ is a regular expression line anchor - it restrict matches to occur only at the start of a line.
In the example you give, there is an empty pattern after the anchor, so it matches lines that start with anything - making it equivalent to simply using
grep -c ''
Either way it returns a line count - equivalent to doing
ps -e | wc -l