I am using
ps -ef | grep java | wc -l
to find the number of java processes running at any given time.
The above command obviously counts the "ps -ef | grep java" command also in the result.
To avoid this, I found out that I could use
ps -ef | grep [j]ava | wc -l
and it works fine. However, I would like to figure out the reason why it is able to skip the original command from the results.