GNU bug report logs - #24382
grep should support -l and -n together

Previous Next

Package: grep;

Reported by: Mathieu Jobin <somekool <at> gmail.com>

Date: Tue, 6 Sep 2016 15:36:02 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 24382 <at> debbugs.gnu.org
Subject: bug#24382: grep should support -l and -n together
Date: Tue, 6 Sep 2016 09:57:11 -0700
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)





This bug report was last modified 8 years and 289 days ago.

Previous Next


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