grep by paragraph

smcg4191 at frii.com smcg4191 at frii.com
Fri Aug 30 14:18:41 UTC 2013


On 08/30/2013 02:50 AM, Timothy Murphy wrote:
> Is there an option for grep, or some similar program,
> that will print out a whole paragraph -
> defined as the section between two blank lines -
> containing a given word or phrase?
> 
> Such as the above 4 lines.
> If not, can anyone suggest a simple script that will do this?

agrep (Approximate Grep, http://www.tgries.de/agrep/) is useful
for that kind of thing.

  agrep -d '\n\n' some-word [files...]

agrep is in the Fedora repo (or at least it was as of f15, not 
sure about later).



More information about the users mailing list