Boy they really blew it when they invented -c, (info "(grep) General Output Control")
‘-c’ ‘--count’ Suppress normal output; instead print a count of matching lines for each input file. With the ‘-v’ (‘--invert-match’) option, count non-matching lines. (‘-c’ is specified by POSIX.) Who in the world ever wants to know about the zero match counts (:0)? ;-) OK, well then add some extra switch for the rest of us... or at least the INFO page should mention how the pros filter them out. #1 time find * -name \*.html | xargs grep -l staticmap | xargs grep -c staticmap | head -n 3 location/directions/zaokeng.html:1 location/yaokeng_road.html:1 location/yaokeng_road2.html:1 real 0m0.015s user 0m0.013s sys 0m0.002s #2 time find * -name \*.html | xargs grep -c staticmap | grep -v :0$ | head -n 3 comm/air/m750/trail.html:1 comm/air/m750/index.html:1 geo/house_numbering/taizhong/dongshi/index.html:1 real 0m0.017s user 0m0.011s sys 0m0.004s (#1 is a big waste, but the real time is randomly a little shorter, as it takes larger inputs so really see the difference.) Anyway I've never ever wanted the :0s. Wait! Maybe "-cl" or "-lc" will give us what we want! Alas, they are just equivalent to "-l". (As I suppose that fact is not documented, perhaps it could be given a new (non-backwardly compatible, alas) definition...)