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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: grep; Severity: wishlist; Reported by: 積丹尼 Dan Jacobson <jidanni@HIDDEN>; dated Sat, 20 Apr 2019 12:22:03 UTC; Maintainer for grep is bug-grep@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Apr 2019 12:21:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 20 08:21:59 2019
Received: from localhost ([127.0.0.1]:45886 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hHp0J-0000CH-I6
	for submit <at> debbugs.gnu.org; Sat, 20 Apr 2019 08:21:59 -0400
Received: from eggs.gnu.org ([209.51.188.92]:39799)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jidanni@HIDDEN>) id 1hHp0H-0000Bq-0P
 for submit <at> debbugs.gnu.org; Sat, 20 Apr 2019 08:21:57 -0400
Received: from lists.gnu.org ([209.51.188.17]:40494)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <jidanni@HIDDEN>) id 1hHp0B-0003ys-T1
 for submit <at> debbugs.gnu.org; Sat, 20 Apr 2019 08:21:51 -0400
Received: from eggs.gnu.org ([209.51.188.92]:54180)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <jidanni@HIDDEN>) id 1hHp0A-0001C7-Tl
 for bug-grep@HIDDEN; Sat, 20 Apr 2019 08:21:51 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: *
X-Spam-Status: No, score=1.8 required=5.0 tests=BAYES_50,FROM_EXCESS_BASE64,
 RCVD_IN_DNSWL_NONE,URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <jidanni@HIDDEN>) id 1hHp0A-0003yA-0A
 for bug-grep@HIDDEN; Sat, 20 Apr 2019 08:21:50 -0400
Received: from ostrich.birch.relay.mailchannels.net ([23.83.209.138]:5367)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <jidanni@HIDDEN>) id 1hHp09-0003wd-LP
 for bug-grep@HIDDEN; Sat, 20 Apr 2019 08:21:49 -0400
X-Sender-Id: dreamhost|x-authsender|jidanni@HIDDEN
Received: from relay.mailchannels.net (localhost [127.0.0.1])
 by relay.mailchannels.net (Postfix) with ESMTP id 2A7F36A1A52
 for <bug-grep@HIDDEN>; Sat, 20 Apr 2019 12:21:47 +0000 (UTC)
Received: from pdx1-sub0-mail-a9.g.dreamhost.com
 (100-96-7-60.trex.outbound.svc.cluster.local [100.96.7.60])
 (Authenticated sender: dreamhost)
 by relay.mailchannels.net (Postfix) with ESMTPA id 8D26D6A1576
 for <bug-grep@HIDDEN>; Sat, 20 Apr 2019 12:21:46 +0000 (UTC)
X-Sender-Id: dreamhost|x-authsender|jidanni@HIDDEN
Received: from pdx1-sub0-mail-a9.g.dreamhost.com ([TEMPUNAVAIL].
 [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384)
 by 0.0.0.0:2500 (trex/5.17.2); Sat, 20 Apr 2019 12:21:47 +0000
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|jidanni@HIDDEN
X-MailChannels-Auth-Id: dreamhost
X-Inform-Thoughtful: 0d835e6a6b6f8944_1555762906997_1399156276
X-MC-Loop-Signature: 1555762906997:763595910
X-MC-Ingress-Time: 1555762906997
Received: from pdx1-sub0-mail-a9.g.dreamhost.com (localhost [127.0.0.1])
 by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTP id 3760E80182
 for <bug-grep@HIDDEN>; Sat, 20 Apr 2019 05:21:45 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to
 :subject:date:message-id:mime-version:content-type
 :content-transfer-encoding; s=jidanni.org; bh=tZgo42LmJUDK0uwBjD
 HyJs8c0Cw=; b=eewgjD+foJL/uVSdCnAC1/Op6Nz7f5OWiD5gp7AeovOiEagFnX
 cy/cQ6LsTVEvC/TOk/zr8HHpa9C23Y9I9oeAZeh4Zo5+u2lbULTMs89cfJsnGakb
 ZpW5GD4Un1Xvmg8nHNOpMvbrUdCty1vZKNEfFlDGg4+MsldemLpo8MEzQ=
Received: from jidanni.org (1-170-81-233.dynamic-ip.hinet.net [1.170.81.233])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256
 bits)) (No client certificate requested)
 (Authenticated sender: jidanni@HIDDEN)
 by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTPSA id 7DE8280181
 for <bug-grep@HIDDEN>; Sat, 20 Apr 2019 05:21:44 -0700 (PDT)
X-DH-BACKEND: pdx1-sub0-mail-a9
From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson <jidanni@HIDDEN>
To: bug-grep@HIDDEN
Subject: Document the recommended way to get the :0s out of -c output
Date: Sat, 20 Apr 2019 20:13:23 +0800
Message-ID: <878sw4zxgc.5.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
X-VR-OUT-STATUS: OK
X-VR-OUT-SCORE: 0
X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduuddrgedtgdegudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkfggtgfgsehtkeertddttdejnecuhfhrohhmpejnnjjnucffrghnucflrggtohgsshhonhcuoehjihgurghnnhhisehjihgurghnnhhirdhorhhgqeenucfkphepuddrudejtddrkedurddvfeefnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehjihgurghnnhhirdhorhhgpdhinhgvthepuddrudejtddrkedurddvfeefpdhrvghtuhhrnhdqphgrthhhpeeprehuthhfqdekreeureehiehmpfehnfhiheehsgevkeerpecuffgrnhculfgrtghosghsohhnuceojhhiuggrnhhnihesjhhiuggrnhhnihdrohhrgheqpdhmrghilhhfrhhomhepjhhiuggrnhhnihesjhhiuggrnhhnihdrohhrghdpnhhrtghpthhtohepsghughdqghhrvghpsehgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptd
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 23.83.209.138
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Boy they really blew it when they invented -c,
   (info "(grep) General Output Control")

  =E2=80=98-c=E2=80=99
  =E2=80=98--count=E2=80=99
       Suppress normal output; instead print a count of matching lines fo=
r
       each input file.  With the =E2=80=98-v=E2=80=99 (=E2=80=98--invert=
-match=E2=80=99) option, count
       non-matching lines.  (=E2=80=98-c=E2=80=99 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 stati=
cmap | 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$   | hea=
d -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...)




Acknowledgement sent to 積丹尼 Dan Jacobson <jidanni@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-grep@HIDDEN. Full text available.
Report forwarded to bug-grep@HIDDEN:
bug#35337; Package grep. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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