bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Paul Eggert
Subject: bug#24382: grep should support -l and -n together
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

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)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]