I unearthed a bug in SunOS 5.6 (aka Solaris 2.6, when it's not running away from the Law). It turns out that when using grep -c ("count matches"), if you specify more than one file, any empty file which is not the first can give an incorrect count!

For instance, I made up this example, which you can test if you have access to a SunOS system:

% cd /tmp
% echo foo >1
% touch 2
% ls -l 1 2
-rw-r--r--   1 ariels   research       4 Jun 20 16:22 1
-rw-r--r--   1 ariels   research       0 Jun 20 16:22 2
% grep -c foo 1 2
Note how file `2', which has zero length, manages to contain the string "foo"!

It turns out that this bug is listed in Sun's online support database. They give no known fix.

GNU grep doesn't have this problem. Are you pondering what I'm pondering?