buggrep - Bugs: bug #28588, -m breaks -A


You are not allowed to post comments on this tracker with your current authentication level.

bug #28588: -m breaks -A

Submitted by:  Markus Jochim <angus>
Submitted on:  Wed Jan 13 10:52:50 2010  
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: In Progress
Privacy: PublicAssigned to: None
Open/Closed: Open

Sat Mar 25 16:32:13 2017, comment #4:

I've moved this discussion to the debbugs-based tracker with https://debbugs.gnu.org/26254. Please send any replies to -unavailable-

For the record, my original reply in 2010 is here:

Jim Meyering <meyering>
Project Administrator
Sat Mar 25 07:12:28 2017, comment #3:

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.

$ grep --version
grep (GNU grep) 2.16
$ lsb_release -a
LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch:security-4.0-amd64:security-4.0-noarch:security-4.1-amd64:security-4.1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty

Stuart MacDonald <studog>
Thu Jul 24 07:31:12 2014, comment #2:

This also affects -m1 -C5, very annoying.

Kevin Brubeck Unhammer <unhammer>
Sat Feb 6 13:36:04 2010, comment #1:

I replied on the mailing list:


If you have feedback, please follow up there.

Jim Meyering <meyering>
Project Administrator
Wed Jan 13 10:52:50 2010, original submission:

GNU grep 2.5.4 - Archlinux - zsh

I've created a sample input file to show the bug I've encountered in GNU grep.

this is the first
while this looks like the second
and this smells of third

Doing `grep -m 1 attention sample.input` behaves as expected. Just so do `grep -m 1 -A {1,2,3} attention sample.input`. But as soon as I increase the lines of trailing context to four or more, grep will crop the output.

$ grep -m 1 -A 5 attention sample.input
this is the first
while this looks like the second
and this smells of third

Apparently, any non-first (for -m 1) occurence of the pattern is dropped even though it is part of the "five lines of trailing context" and must therefore be displayed.

I'd love to see this fixed,

Markus Jochim

Markus Jochim <angus>


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by studog (Posted a comment)
  • -unavailable- added by unhammer
  • -unavailable- added by unhammer (Posted a comment)
  • -unavailable- added by meyering (Posted a comment)
  • -unavailable- added by angus (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu Jul 24 07:31:12 2014unhammerCarbon-Copy-=>Added unhammer
    Sat Feb 6 13:36:04 2010meyeringStatusNone=>In Progress

    Back to the top

    Powered by Savane 3.1-cleanup1