Subject: bug#24382: grep should support -l and -n together

From: Paul Eggert <[email-masked]>
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)