X-Loop: help-debbugs@HIDDEN
Subject: bug#24382: grep should support -l and -n together
Resent-From: Mathieu Jobin <somekool@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-grep@HIDDEN
Resent-Date: Tue, 06 Sep 2016 15:36:02 +0000
Resent-Message-ID: <handler.24382.B.14731761362676 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 24382
X-GNU-PR-Package: grep
X-GNU-PR-Keywords:
To: 24382 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-grep@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.14731761362676
(code B ref -1); Tue, 06 Sep 2016 15:36:02 +0000
Received: (at submit) by debbugs.gnu.org; 6 Sep 2016 15:35:36 +0000
Received: from localhost ([127.0.0.1]:51502 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1bhIPK-0000gr-Ph
for submit <at> debbugs.gnu.org; Tue, 06 Sep 2016 11:35:35 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59436)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <somekool@HIDDEN>) id 1bhHUx-0007cB-LH
for submit <at> debbugs.gnu.org; Tue, 06 Sep 2016 10:37:20 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from <somekool@HIDDEN>) id 1bhHUr-00009d-H7
for submit <at> debbugs.gnu.org; Tue, 06 Sep 2016 10:37:10 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level:
X-Spam-Status: No, score=0.8 required=5.0 tests=AC_DIV_BONANZA,BAYES_50,
FREEMAIL_FROM,HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:39255)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from <somekool@HIDDEN>) id 1bhHUr-00008v-Dw
for submit <at> debbugs.gnu.org; Tue, 06 Sep 2016 10:37:09 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50357)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from <somekool@HIDDEN>) id 1bhHUp-00065q-0e
for bug-grep@HIDDEN; Tue, 06 Sep 2016 10:37:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from <somekool@HIDDEN>) id 1bhHUn-00007T-6m
for bug-grep@HIDDEN; Tue, 06 Sep 2016 10:37:05 -0400
Received: from mail-yb0-x22e.google.com ([2607:f8b0:4002:c09::22e]:32828)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from <somekool@HIDDEN>) id 1bhHUn-00007E-2X
for bug-grep@HIDDEN; Tue, 06 Sep 2016 10:37:05 -0400
Received: by mail-yb0-x22e.google.com with SMTP id d205so60427773ybh.0
for <bug-grep@HIDDEN>; Tue, 06 Sep 2016 07:37:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
h=mime-version:from:date:message-id:subject:to;
bh=YUJv+e+hFSkPTXHQJxxlLerUVArfXVf19RlPeBwi1Ko=;
b=L/HgK64mQBSudO83JUgGHJaOolDZLNdBw+eZli5iO0g8ssvw5XKBiF6OQSZaaGc2FF
BPZaVrHbNZnLkKNjNdpgiFTkNxkx+5Z1eD5M6MdNkBWMZ1ydeTQN6IrxjoXLA9LkJzPa
WjczBi1EhRHFB5BKfmPkU5RXluNM2S3mt2KdnYVW/ymV0fl3o+WdtBipJ7gSrW1iLeph
dvPchZQu/dEJc+REP20q4KKoy2Bum95dkhP657tAmGNKZgq8d5r1DxfcZlQBDEvBd8SX
KtPtCRZ/Zjf68kT7+TGl7h7/y7Dq6GKF+/PWBBUgZ3oVlXURJOLyvJHGGd5XUQ9Wf4xr
Gn9A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20130820;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=YUJv+e+hFSkPTXHQJxxlLerUVArfXVf19RlPeBwi1Ko=;
b=GdOYAXYqlS2JSXDYFijkUXC5a61uyeWddgARuGycuB9a7OFKTbG3G9UQjLtecX4RWY
q6nc4knT4VckDqb8+8GOwB3B/n9o3KXdX5qPTCwT7WQ7pS/EvVbAP+uKx/QyQD4ZH0bQ
McldBAwAN9FSi53yPNHt8OTzcwH2DoSDkokm9nLxUTQ3deg32tmFE51a7vpDioFX/VG7
RFmTMYxpjMcc0l6fX28S+rnAFStZ/vQc3CYDiL1qi7/dBlimhWVX5pjl9XJz31tQj+FG
rI9sZh1S3sn9BenJh54PihR0MBGFN7AMVzCVuttn5B/KU3pfPWFbZK2RusrvjcZhkaxr
gI7w==
X-Gm-Message-State: AE9vXwOfzDHJzD4N9T9MWbXdl88/aZoHgercNu6XzDSyAhLbUm/uGaEXbheDkBRhupAhyGKe6T7pr68Ie2Wheg==
X-Received: by 10.107.186.7 with SMTP id k7mr5112135iof.3.1473172623465; Tue,
06 Sep 2016 07:37:03 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.36.211.130 with HTTP; Tue, 6 Sep 2016 07:36:22 -0700 (PDT)
From: Mathieu Jobin <somekool@HIDDEN>
Date: Tue, 6 Sep 2016 10:36:22 -0400
Message-ID: <CAErp+DJQnKHe7BdUxp7vhLDnhzdSVuXUgYamr8htW7YG-=VxUw@HIDDEN>
Content-Type: multipart/alternative; boundary=94eb2c06ebd0ea2544053bd7bafd
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Mailman-Approved-At: Tue, 06 Sep 2016 11:35:29 -0400
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: -4.0 (----)
--94eb2c06ebd0ea2544053bd7bafd
Content-Type: text/plain; charset=UTF-8
I like using
> grep -rn pattern dir
a lot because it returns all the result with the line numbers
I think its one of the most common use case of grep.
recently I started using
> grep -rl pattern dir
only returning the list of files, without the content appended.
I find that really useful
but when using -rl , -n is ignored, which is sad, because I could pipe in
my editor and it would open the files at the proper line
for example
> grep -rln "[^a-z]if .\+ = .\+" app | xargs kate
unfortunately, the line numbers is not present on the grep output here
should you chose not to support this, then it should probably error out
cheers,
--
Mathieu Jobin
--94eb2c06ebd0ea2544053bd7bafd
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div><div><div><div><div><div><div><div><div><div>I l=
ike using <br><br></div>> grep -rn pattern dir<br><br></div>a lot becaus=
e it returns all the result with the line numbers<br></div>I think its one =
of the most common use case of grep.<br><br></div>recently I started using =
<br><br></div>> grep -rl pattern dir<br><br></div>only returning the lis=
t of files, without the content appended.<br></div>I find that really usefu=
l<br><br></div>but when using -rl , -n is ignored, which is sad, because I =
could pipe in my editor and it would open the files at the proper line<br><=
br></div>for example<br><br>> grep -rln "[^a-z]if .\+ =3D .\+"=
app=C2=A0 | xargs kate<br><br></div>unfortunately, the line numbers is not=
present on the grep output here<br><br><br></div><div>should you chose not=
to support this, then it should probably error out<br><br></div>cheers,<br=
><br clear=3D"all"><div><div><div><div><div><div><div><div><div><div><div><=
div><div><div><br>-- <br><div class=3D"gmail_signature">Mathieu Jobin<br><b=
r></div>
</div></div></div></div></div></div></div></div></div></div></div></div></d=
iv></div></div>
--94eb2c06ebd0ea2544053bd7bafd--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Mathieu Jobin <somekool@HIDDEN> Subject: bug#24382: Acknowledgement (grep should support -l and -n together) Message-ID: <handler.24382.B.14731761362676.ack <at> debbugs.gnu.org> References: <CAErp+DJQnKHe7BdUxp7vhLDnhzdSVuXUgYamr8htW7YG-=VxUw@HIDDEN> X-Gnu-PR-Message: ack 24382 X-Gnu-PR-Package: grep Reply-To: 24382 <at> debbugs.gnu.org Date: Tue, 06 Sep 2016 15:36:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-grep@HIDDEN If you wish to submit further information on this problem, please send it to 24382 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 24382: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D24382 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN
Subject: bug#24382: grep should support -l and -n together
Resent-From: Paul Eggert <eggert@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-grep@HIDDEN
Resent-Date: Tue, 06 Sep 2016 16:58:02 +0000
Resent-Message-ID: <handler.24382.B.147318104616949 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 24382
X-GNU-PR-Package: grep
X-GNU-PR-Keywords:
To: 24382 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-grep@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.147318104616949
(code B ref -1); Tue, 06 Sep 2016 16:58:02 +0000
Received: (at submit) by debbugs.gnu.org; 6 Sep 2016 16:57:26 +0000
Received: from localhost ([127.0.0.1]:51602 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1bhJgc-0004PJ-Js
for submit <at> debbugs.gnu.org; Tue, 06 Sep 2016 12:57:26 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48041)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <eggert@HIDDEN>) id 1bhJgb-0004P7-7n
for submit <at> debbugs.gnu.org; Tue, 06 Sep 2016 12:57:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from <eggert@HIDDEN>) id 1bhJgV-00018P-21
for submit <at> debbugs.gnu.org; Tue, 06 Sep 2016 12:57:20 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level:
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:35947)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from <eggert@HIDDEN>) id 1bhJgU-000188-VB
for submit <at> debbugs.gnu.org; Tue, 06 Sep 2016 12:57:18 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:38994)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from <eggert@HIDDEN>) id 1bhJgS-0004Hh-N8
for bug-grep@HIDDEN; Tue, 06 Sep 2016 12:57:17 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from <eggert@HIDDEN>) id 1bhJgP-000173-FV
for bug-grep@HIDDEN; Tue, 06 Sep 2016 12:57:16 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:45814)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from <eggert@HIDDEN>) id 1bhJgP-00016m-9l
for bug-grep@HIDDEN; Tue, 06 Sep 2016 12:57:13 -0400
Received: from localhost (localhost [127.0.0.1])
by zimbra.cs.ucla.edu (Postfix) with ESMTP id 82320160DFF
for <bug-grep@HIDDEN>; Tue, 6 Sep 2016 09:57:12 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
with ESMTP id Bbsz8ADaxKIs for <bug-grep@HIDDEN>;
Tue, 6 Sep 2016 09:57:11 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
by zimbra.cs.ucla.edu (Postfix) with ESMTP id 684D116111A
for <bug-grep@HIDDEN>; Tue, 6 Sep 2016 09:57:11 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
with ESMTP id lqnuXw_CIPSg for <bug-grep@HIDDEN>;
Tue, 6 Sep 2016 09:57:11 -0700 (PDT)
Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200])
by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 51CE7160DFF
for <bug-grep@HIDDEN>; Tue, 6 Sep 2016 09:57:11 -0700 (PDT)
References: <CAErp+DJQnKHe7BdUxp7vhLDnhzdSVuXUgYamr8htW7YG-=VxUw@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Message-ID: <dea19395-05ed-41d0-584b-341220b09042@HIDDEN>
Date: Tue, 6 Sep 2016 09:57:11 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.2.0
MIME-Version: 1.0
In-Reply-To: <CAErp+DJQnKHe7BdUxp7vhLDnhzdSVuXUgYamr8htW7YG-=VxUw@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
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: -4.0 (----)
On 09/06/2016 07:36 AM, Mathieu Jobin wrote:
> should you chose not to support this, then it should probably error out
Hmm, well, as I understand it POSIX requires that -n be ignored if -l is
also specified; see:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html
I suppose we could add an option saying "please output file names and
line numbers but not line contents". This option would act like -o,
except it would omit all the line contents instead of just the
non-matching part. Seems like a bit of a specialized use, though.
Can't you get something close to what you want, by asking the editor to
search for the matching lines? For vi, you can do the following, and I
assume your editor has a similar option:
vi +/PATTERN $(grep -l PATTERN FILES)
Received: (at control) by debbugs.gnu.org; 6 Sep 2016 16:58:11 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 06 12:58:11 2016 Received: from localhost ([127.0.0.1]:51608 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1bhJhK-0004Qo-T1 for submit <at> debbugs.gnu.org; Tue, 06 Sep 2016 12:58:11 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:57612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eggert@HIDDEN>) id 1bhJhJ-0004QY-BM for control <at> debbugs.gnu.org; Tue, 06 Sep 2016 12:58:09 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 8EE71160DFF for <control <at> debbugs.gnu.org>; Tue, 6 Sep 2016 09:58:03 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id rHPxp6tRZRZy for <control <at> debbugs.gnu.org>; Tue, 6 Sep 2016 09:58:02 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E05F516111A for <control <at> debbugs.gnu.org>; Tue, 6 Sep 2016 09:58:02 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TeV6oVh99uGy for <control <at> debbugs.gnu.org>; Tue, 6 Sep 2016 09:58:02 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id CA5A9160DFF for <control <at> debbugs.gnu.org>; Tue, 6 Sep 2016 09:58:02 -0700 (PDT) To: control <at> debbugs.gnu.org From: Paul Eggert <eggert@HIDDEN> Subject: 24382 is wishlist Organization: UCLA Computer Science Department Message-ID: <9c713cb6-a40d-fc06-2982-b102ed117c69@HIDDEN> Date: Tue, 6 Sep 2016 09:58:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: control 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: -1.1 (-) severity 24382 wishlist
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.