When i use 'ps', 'egrep' and 'wc' command to count number of processes, it gives me wrong value. I am running the command in 'Solaris 9' machine. Please assist in understanding the issue.MyServer $ ps -fu root | egrep -v 'bash|ksh|ssh|ef|mailx|nohup|defunct|ps|sh|FND'     UID   PID  PPID  C    STIME TTY      TIME CMD root 16267 16171  0   Jan 28 ?        0:18 xyz root 16269 16171  0   Jan 28 ?        0:07 abc root 16268 16171  0   Jan 28 ?        0:07 ghiMyServer $Only 4 (3 processes + header) lines shown in output. But when i use below command it returns the output as 5MyServer $ ps -fu root | egrep -v 'bash|ksh|ssh|ef|mailx|nohup|defunct|ps|sh|FND' | wc -l       5On the otherhand, when I echo the output to a file and count the number of lines, it works perfectly normal.MyServer $ ps -fu root | egrep -v 'bash|ksh|ssh|ef|mailx|nohup|defunct|ps|sh|FND' >temp && cat temp | wc -l       4More description related to 'egrep' and 'egrep -v':Why does 'egrep' working properly without '-v' option? But not with '-v'?MyServer$ ps -fu root | egrep '20755|13800' root 20755 20751  0 12:14:29 pts/5    0:00 more -s /tmp/mpWGa4mO root  1223 26407  0 12:57:28 pts/15   0:00 egrep 20755|13800MyServer$ ps -fu root | egrep '20755|13800' | wc -l       2MyServer$MyServer$ ps -fu root | egrep -v 'usr|apps|sql|sh'     UID   PID  PPID  C    STIME TTY      TIME CMD root  3448 26407  0 12:57:42 pts/15   0:00 ps -fu root root 20755 20751  0 12:14:29 pts/5    0:00 more -s /tmp/mpWGa4mOMyServer$ ps -fu root | egrep -v 'usr|apps|sql|sh' | wc -l       4MyServer$
Solaris 9 - Word Count (wc) command gives wrong output with 'grep -v and ps'
solaris;ps;wc