A little help with SED please - cla

j.l.wood jlw at lznv.ATT.COM
Fri Apr 22 07:42:14 AEST 1988


In article <142700030 at occrsh.ATT.COM>, rjd at occrsh.ATT.COM writes:
> 
> :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 <text file> | awk -f script
> 
> where 'script' is a file containing this:

Some Stuff Deleted:

The following awk command line seems to do what you want:

	cat <text file> |\
	awk '/BEGIN/,/END/ { if( $0 != "BEGIN" && $0 != "END" ) print }'



Joe Wood
lznv!jlw

I
n
e
w
s

f
o
d
d
e
r

m
o
r
e

f
o
d
d
e
r



More information about the Comp.unix.wizards mailing list