From unknown Sat Jun 14 19:22:49 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35337: Document the recommended way to get the :0s out of -c output Resent-From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Sat, 20 Apr 2019 12:22:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35337 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: 35337@debbugs.gnu.org X-Debbugs-Original-To: bug-grep@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.1555762919765 (code B ref -1); Sat, 20 Apr 2019 12:22:03 +0000 Received: (at submit) by debbugs.gnu.org; 20 Apr 2019 12:21:59 +0000 Received: from localhost ([127.0.0.1]:45886 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hHp0J-0000CH-I6 for submit@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 ) id 1hHp0H-0000Bq-0P for submit@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 ) id 1hHp0B-0003ys-T1 for submit@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 ) id 1hHp0A-0001C7-Tl for bug-grep@gnu.org; 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 ) id 1hHp0A-0003yA-0A for bug-grep@gnu.org; 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 ) id 1hHp09-0003wd-LP for bug-grep@gnu.org; Sat, 20 Apr 2019 08:21:49 -0400 X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 2A7F36A1A52 for ; 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 ; Sat, 20 Apr 2019 12:21:46 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org 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@jidanni.org 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 ; 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@jidanni.org) by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTPSA id 7DE8280181 for ; Sat, 20 Apr 2019 05:21:44 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a9 From: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Date: Sat, 20 Apr 2019 20:13:23 +0800 Message-ID: <878sw4zxgc.5.fsf@jidanni.org> 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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...)