buggrep - Bugs: bug #28906, grep -Ax -q should print context...

 
 

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

bug #28906: grep -Ax -q should print context but not matching line

Submitted by:  Chris <seahen>
Submitted on:  Mon 15 Feb 2010 05:18:54 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Mon 08 Mar 2010 08:52:07 AM UTC, comment #2:

With git grep, you can use

grep --no-group-separator -A1 foo | grep -v foo

Thank you for the bug report. This bug has been fixed in the
development sources, which can be downloaded using git from
git://git.sv.gnu.org/grep.git

Paolo Bonzini <bonzini>
Fri 19 Feb 2010 01:28:52 PM UTC, comment #1:

I don't think it would be adequate to shoehorn this into -q. You can do this with

grep -A1 foo | grep -v foo

Note that the output would be

quick
---
lazy

Another related feature that would make sense is suppression of the group separator, for which I'll open a separate bug.

Paolo Bonzini <bonzini>
Mon 15 Feb 2010 05:18:54 PM UTC, original submission:

Binary package hint: grep
Version: 2.5.3~dfsg-6ubuntu1

It would occasionally be useful to be able to output only the lines immediately before or after the matching lines, without printing the matching lines themselves. The logical way to do this would be to use e.g. grep -A1 -q (since -A1 adds the line after the match and -q suppresses normal output). But this doesn't work; instead there is no output.

Steps to reproduce:
1. Create a file test.txt whose contents are:
the
quick
brown
fox
the
lazy
dog

2. grep -A1 -q the test.txt

Expected output:
quick
lazy

Actual output: nothing.

Reposting from downstream at https://bugs.launchpad.net/ubuntu/+source/grep/+bug/396237

Chris <seahen>

 

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 bonzini (Posted a comment)
  • -unavailable- added by seahen (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
    Mon 08 Mar 2010 08:52:07 AM UTCbonziniStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1