Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!mailrus!tut.cis.ohio-state.edu!osu-cis!att!att-ih!occrsh!occrsh.ATT.COM!rjd From: rjd@occrsh.ATT.COM Newsgroups: comp.unix.wizards Subject: Re: A little help with SED please - cla Message-ID: <142700030@occrsh.ATT.COM> Date: 20 Apr 88 18:16:00 GMT References: <5490@sigi.Colorado.EDU> Lines: 43 Nf-ID: #R:sigi.Colorado.EDU:-549000:occrsh.ATT.COM:142700030:000:723 Nf-From: occrsh.ATT.COM!rjd Apr 20 12:16:00 1988 :I need an sed line (or some gory pipeline) to extract the data between ^^^^^^^^^^^^^^^^^^^^^^ :BEGIN and END. : :I should have added the following: : : >I have a text file of this form: : [... junk ...] : > BEGIN : > 1 : > 2 : > 3 : > END : [... junk ...] : > BEGIN : > 4 : > 5 : > 6 : > END : [... junk ...] Is "awk" gory enough??? :-) Here's an awk script: cat | awk -f script where 'script' is a file containing this: --------- cut here --------- BEGIN { prnt=0 bgn=0 } /BEGIN/ && $0 == "BEGIN" {prnt=1;bgn=1} /END/ && $0 == "END" {prnt=0} NF > 0 { if( prnt == 1 && bgn != 1) print $0 bgn=0 } --------- cut here --------- Randy