DIAGNOSTICS
Normally, exit status is 0 if selected lines are found and 1 otherwise. But the exit status is 2 if an error occurred, unless the -q or --quiet or --silent option is used and a selected line is found.
[kimmo@firewall ~]$ cat /sys/conf/NOTES | grep -Em1 '^[a-z]+[[:blank:]]+[a-z]+$'
device loop
[kimmo@firewall ~]$ echo $?
0
[kimmo@firewall ~]$
I've read that.SirDice said:Not according to grep(1):
# cat /sys/conf/NOTES | grep -Em1 '^device' 0 /root/sh_testground
device hwpmc # Driver (also a loadable module)
blackhole# 141 /root/sh_testground
# cat /sys/conf/NOTES | grep -E '^device'
... lots of output ...
0 /root/sh_testground
/* We register via atexit() to test stdout. */
exit (errseen ? 2 : status);