[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep : Paragraph Parameter

From: Stepan Kasal
Subject: Re: grep : Paragraph Parameter
Date: Wed, 25 May 2005 17:42:26 +0200
User-agent: Mutt/1.4.1i

Hello Martin,

thank you very much for your suggestion.

> Here is the part of the manual page on AIX:
> -p[Separator] 
>    Displays the entire paragraph containing matched lines. [...]
>    The default paragraph separator is a blank line.

This looks like a perfect job for awk (gawk, or any POSIX implementation):

 awk '/pattern/' RS= 'ORS=\n\n' filename

or a less terse and less cryptic version:

 awk 'BEGIN{RS="";ORS="\n\n"} /pattern/{print}' filename

RS is a ``record separator'' and empty string means that empty lines separate
With gawk (GNU awk) and other advanced flavours of awk, you can have a
regular expression for RS. 

See `info awk', or a book on the topic, to learn the details.

Thus I don't think it's much important to implement this fuctionality to

Have a nice day,
        Stepan Kasal

reply via email to

[Prev in Thread] Current Thread [Next in Thread]