On Fri, 30 Aug 2013, Timothy Murphy wrote:

Dave Mitchell wrote:

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?

The perl one-liner below demonstrates this. Setting the $/ (input record
separator) var to the empty string causes perl to read in "lines" a
paragraph at a time.

    $ perl -e'$/=""; while (<>) { print if /green/ }' /tmp/text

Thanks for the solutions.

I gather there is no method using grep or one of its variants?

sed could do it.
I don't have a recipe on me at the moment.

--
Michael   henne...@web.cs.ndsu.nodak.edu
"On Monday, I'm gonna have to tell my kindergarten class,
whom I teach not to run with scissors,
that my fiance ran me through with a broadsword."  --  Lily
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org

Reply via email to