GNU bug report logs - #35337
Document the recommended way to get the :0s out of -c output

Previous Next

Package: grep;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Sat, 20 Apr 2019 12:22:03 UTC

Severity: wishlist

To reply to this bug, email your comments to 35337 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#35337; Package grep. (Sat, 20 Apr 2019 12:22:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Sat, 20 Apr 2019 12:22:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-grep <at> gnu.org
Subject: Document the recommended way to get the :0s out of -c output
Date: Sat, 20 Apr 2019 20:13:23 +0800
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...)




This bug report was last modified 6 years and 56 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.