GNU bug report logs - #26254
grep's -m breaks -A

Previous Next

Package: grep;

Reported by: Jim Meyering <jim <at> meyering.net>

Date: Sat, 25 Mar 2017 16:25:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Jim Meyering <jim <at> meyering.net>
Subject: bug#26254: closed (Re: bug#26254: grep's -m breaks -A)
Date: Thu, 22 Jun 2017 02:02:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#26254: grep's -m breaks -A

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 26254 <at> debbugs.gnu.org.

-- 
26254: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=26254
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Jim Meyering <jim <at> meyering.net>
Cc: 26254-done <at> debbugs.gnu.org, Nicholas Sushkin <nsushkin <at> openfinance.com>,
 Stuart MacDonald <stuartm.coding <at> gmail.com>
Subject: Re: bug#26254: grep's -m breaks -A
Date: Wed, 21 Jun 2017 19:01:41 -0700
On 06/21/2017 06:27 PM, Jim Meyering wrote:
> Thanks for all of that careful work. It looks fine to me.
> Please add a reference to this bug number, 26254, in the commit log.

Thanks, done.

[Message part 3 (message/rfc822, inline)]
From: Jim Meyering <jim <at> meyering.net>
To: bug-grep <at> gnu.org
Cc: Stepan Kasal <kasal <at> ucw.cz>, Kevin Brubeck Unhammer <unhammer <at> fsfe.org>,
 Paul Eggert <eggert <at> cs.ucla.edu>, Stuart MacDonald <stuartm.coding <at> gmail.com>,
 Markus Jochim <ich <at> markusjochim.de>
Subject: Re: grep's -m breaks -A
Date: Sat, 25 Mar 2017 09:23:31 -0700
On Sat, Mar 25, 2017 at 12:12 AM, Stuart MacDonald
<INVALID.NOREPLY <at> gnu.org> wrote:
> Follow-up Comment #3, bug #28588 (project grep):
>
> I just ran into this, trying to grep for the start of a problem in a 60 Gb
> syslog. :-(
>
> Context must always be printed; the current behaviour is unexpected,
> surprising, and counter-intuitive, says the lifetime unified diff user.

Please keep the discussion on the mailing list, not on that obsolete
tracker. I've added our bug-grep@ address, so this thread will
automatically get a new bug number in the debbugs-based tracker.

I responded to the OP back in 2010:

  https://lists.gnu.org/archive/html/bug-grep/2010-02/msg00002.html

Repeating part of that here, this behavior is documented, and now tested:

    `-m NUM'
    `--max-count=NUM'
         Stop reading a file after NUM matching lines.  If the input is
         standard input from a regular file, and NUM matching lines are
         output, `grep' ensures that the standard input is positioned just
         after the last matching line before exiting, regardless of the
         presence of trailing context lines.  This enables a calling
         process to resume a search.  For example, the following shell
         script makes use of it:

              while grep -m 1 PATTERN
              do
                echo xxxx
              done < FILE

Notice how it says grep takes care to position the standard input that
only the specified maximum number of matches are "read". This means
*not* printing all of the requested trailing context when that context
would contain any additional match.



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

Previous Next


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