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


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

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

Submitted by:  None
Submitted on:  Sat 24 Sep 2005 12:03:47 PM UTC  
Votes:  21  
Category:  None Severity:  1 - Wish
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

( Jump to the original submission)

Wed 16 Feb 2011 03:33:02 PM UTC, 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 09 May 2006 06:37:46 AM UTC, 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 08 May 2006 08:04:28 PM UTC, 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 17 Oct 2005 12:38:54 AM UTC, comment #4: 

grep -p also features in TRU64

Sun 25 Sep 2005 02:28:49 PM UTC, 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 24 Sep 2005 08:29:43 PM UTC, 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 24 Sep 2005 04:33:39 PM UTC, 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 24 Sep 2005 12:03:47 PM UTC, 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
  • -email is unavailable- added by annihilannic (Voted in favor of this item)
  • -email is unavailable- added by sh4d0w (Posted a comment)
  • -email is unavailable- added by sh4d0w (Voted in favor of this item)

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

    Only logged-in users can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-07-14 annihilannic Carbon-Copy- => Added annihilannic
    2011-02-16 sh4d0w Carbon-Copy- => Added sh4d0w
    2006-05-08 xaminmo Carbon-Copy- => Added -email is unavailable-
        Carbon-Copy- => Added xaminmo
    2005-09-24 charles_levert Severity3 - Normal => 1 - Wish

    Back to the top

    Powered by Savane 3.7