From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <2e4a50a0810241652r38d2aa1ft2b6fb9104d2988ae@mail.gmail.com> Date: Fri, 24 Oct 2008 16:52:11 -0700 From: "Tom Simons" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@9fans.net> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_12049_28527903.1224892331983" References: <20081024170237.68ED28DE7@okapi.maths.tcd.ie> <6520c845566013ada472281bf9c0da73@coraid.com> Subject: Re: [9fans] non greedy regular expressions Topicbox-Message-UUID: 272575de-ead4-11e9-9d60-3106f5b1d025 ------=_Part_12049_28527903.1224892331983 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Is awk available? This worked for me, but it's not on Plan9. It does copy the newline after the 2nd "ABC" (I wasn't sure if leading or all blank lines should be deleted). $ cat a.data dflkdl dlkrwo3je4ogjmdmxd ABC asassadfasdf asdfasdf asdfasdf CBA hhhhhhhhhhjjjjjjjjjjioioioi sodifs sdfsd ABC dasdfas aasdfa njnjn CBA fkpri34ouijglkrlptgf;c $ awk 'BEGIN {RS = "ABC"; FS = "CBA"}NR == 1 {next}{print $1}' a.data asassadfasdf asdfasdf asdfasdf dasdfas aasdfa njnjn On Fri, Oct 24, 2008 at 3:04 PM, Rudolf Sykora wrote: > > doesn't s/ABC(the_interesting_part)CBA/x/g work for you? > > maybe i don't understand the example. if so, could you explain? > > > > - erik > > I think not. > I have a file say like this > > ABC asassadfasdf asdfasdf asdfasdf CBA hhhhhhhhhhjjjjjjjjjjioioioi > sodifs > sdfsd > ABC > dasdfas aasdfa > njnjn CBA > > and I want to get > > ' asassadfasdf asdfasdf asdfasdf ' > 'dasdfas aasdfa' > 'njnjn' > > where I added apostrophes to see the spaces on indivial lines. Simply: > give me everything that is between delimiters (ABC and CBA). > > Ruda > > ------=_Part_12049_28527903.1224892331983 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Is awk available?  This worked for me, but it's not on Plan9.  It does copy the newline after the 2nd "ABC" (I wasn't sure if leading or all blank lines should be deleted).
$ cat a.data
 dflkdl dlkrwo3je4ogjmdmxd
ABC asassadfasdf asdfasdf asdfasdf CBA hhhhhhhhhhjjjjjjjjjjioioioi
sodifs
sdfsd
ABC
dasdfas aasdfa
njnjn CBA
fkpri34ouijglkrlptgf;c
$ awk 'BEGIN {RS = "ABC"; FS = "CBA"}NR == 1 {next}{print $1}' a.data
 asassadfasdf asdfasdf asdfasdf

dasdfas aasdfa
njnjn

On Fri, Oct 24, 2008 at 3:04 PM, Rudolf Sykora <rudolf.sykora@gmail.com> wrote:
> doesn't s/ABC(the_interesting_part)CBA/x/g work for you?
> maybe i don't understand the example.  if so, could you explain?
>
> - erik

I think not.
I have a file say like this

ABC asassadfasdf asdfasdf asdfasdf CBA hhhhhhhhhhjjjjjjjjjjioioioi
sodifs
sdfsd
ABC
dasdfas aasdfa
njnjn CBA

and I want to get

' asassadfasdf asdfasdf asdfasdf '
'dasdfas aasdfa'
'njnjn'

where I added apostrophes to see the spaces on indivial lines. Simply:
give me everything that is between delimiters (ABC and CBA).

Ruda


------=_Part_12049_28527903.1224892331983--