🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.editors
Article #2773

Re: Multiple line regexps

#2773
From: Geoff Clare
Date: Thu, 06 Jun 1991 13:28
18 lines
1125 bytes
tchrist@convex.COM (Tom Christiansen) writes:

>    perl -00 -ne 'print /(.*\n)/' some_file

>The -00 put us in paragraph mode, and the (.*\n) isolates the first
>line of each paragraph for printing.

The exact equivalent in awk is:

    awk 'BEGIN { RS=""; FS="\n" }
	 { print $1 }' some_file
    
The RS="" makes blank lines the record separator, and the FS="\n" allows
the first line of the record to be obtained using "$1".

-- 
Geoff Clare <gwc@root.co.uk>  (Dumb American mailers: ...!uunet!root.co.uk!gwc)
UniSoft Limited, London, England.   Tel: +44 71 729 3773   Fax: +44 71 729 3273
Technical Details
Message-ID: <2732@root44.co.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!aunro!lll-winken!uunet!mcsun!ukc!pyrltd!root44!gwc
References: <1991Jun2.231351.10229@trl.oz.au> <1991Jun03.045458.4972@convex.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!aunro!lll-winken!uunet!mcsun!ukc!pyrltd!root44!gwc
From: gwc@root.co.uk (Geoff Clare)
Newsgroups: comp.editors
Subject: Re: Multiple line regexps
Keywords: regexp, multiple lines
Message-ID: <2732@root44.co.uk>
Date: 6 Jun 91 13:28:28 GMT
References: <1991Jun2.231351.10229@trl.oz.au> <1991Jun03.045458.4972@convex.com>
Distribution: comp
Organization: UniSoft Ltd., London, England
Lines: 18