buggrep - Bugs: bug #14630, feature request: grep -p[separator]


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

bug #14630: feature request: grep -p[separator]

Submitted by:  None
Submitted on:  Sat Sep 24 12:03:47 2005  
Votes:  11  
Category: NoneSeverity: 1 - Wish
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

(Jump to the original submission Jump to the original submission)

Wed Feb 16 15:33:02 2011, comment #7:

It is very helpful to use grep -p on AIX while processing big logfiles. As a lot of Linux systems used as server, it could be very helpful to implement this feature into GNU grep.

Ubul Vendro <sh4d0w>
Tue May 9 06:37:46 2006, comment #6:

I have an incomplete implementation of a more general feature that defines "universes" or records, and search within them. This feature is borrowed from University of Waterloo's context grep (cgrep).

New feature additions are currently on hold while we iron out pending bug fixes. Once we move on to new future, I'll try to submit a patch to introduce universes.

Tony Abou-Assaleh <taa>
Project Administrator
Mon May 8 20:04:28 2006, comment #5:

I think this is a pretty signifigant feature and would be a GoodThing(tm) to add.

I think the ifconfig example was just an example, not a practical use. I use the -p on AIX to hork out individual records when a record is multiple lines.

It may be a nonstandard option, but it's quick, easy and useful.

There is no comparison between a single, simple flag and using AWK, or writing a PERL one-liner, or whatever.

I know this is very very nontrivial to add, but I highly recommend it because it's the right thing to do on a number of fronts, including GNU being replacements for closed-source tools, usability by the non-UNIX elite/experts, etc.

Josh Davis <xaminmo>
Mon Oct 17 00:38:54 2005, comment #4:

grep -p also features in TRU64

Sun Sep 25 14:28:49 2005, comment #3:

> the -p option available on AIX, Solaris, HP-UX, and possibly
> other platforms.

HP-UX grep does not support the -p option.

Bob Proulx <rwp>
Project Member
Sat Sep 24 20:29:43 2005, comment #2:

After verification, while AIX does support this option, neither do Solaris 10 nor HP-UX 11i (at least according to their online documentation). Also,

/sbin/ifconfig eth0

is a much simpler way to achieve this specific task.

Charles Levert <charles_levert>
Sat Sep 24 16:33:39 2005, comment #1:

"Shocked" sounds somewhat quite strong a word. It's not so surprising that a non-standard extension which can readily be replicated with common existing tools is not implemented in GNU grep.

/sbin/ifconfig -a | awk 'BEGIN {RS = "\n\n"} /127/'
/sbin/ifconfig -a | perl -ne 'BEGIN {$/ = "\n\n"} print if /127/'

Even with its four superfluous spaces characters, the awk solution is even shorter than, say

/sbin/ifconfig -a | grep --input-record-separator='\n\n' 127

given that awk and perl also support an output record separator, which someone would invariably ask to be supported as well with its own distinctive option, sooner or later.

It's easy enough to define a shell function or minimal awk/perl script around either of the two basic one-line templates above.

Do we really need to add this to GNU grep?

Charles Levert <charles_levert>
Sat Sep 24 12:03:47 2005, original submission:

I was shocked to find that GNU grep doesn't support the -p option available on AIX, Solaris, HP-UX, and possibly other platforms. With this option grep displays the paragraph containing each matching line. Paragraphs are delimited by a separator, which follows the same formatting as a search pattern. The default separator is a blank line.

While using grep on other platforms, I've found this option to be quite handy. On my GNU/Linux laptop, I immediately reached for it like this:

# ifconfig | grep -p eth0

But it wasn't there. Could this be added?



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 sh4d0w (Posted a comment)
  • -unavailable- added by sh4d0w (Voted in favor of this item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 11 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 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Feb 16 15:28:41 2011sh4d0wCarbon-Copy-=>Added sh4d0w
    Mon May 8 20:04:28 2006xaminmoCarbon-Copy-=>Added -unavailable-
      Carbon-Copy-=>Added xaminmo
    Sat Sep 24 16:33:39 2005charles_levertSeverity3 - Normal=>1 - Wish

    Back to the top

    Powered by Savane 3.1-cleanup