A little help with SED please

David Sherman dave at lsuc.uucp
Tue Apr 26 15:11:42 AEST 1988


murillo at boulder.Colorado.EDU (Rodrigo Murillo) writes:
>I need an sed line (or some gory pipeline) to extract the data between
>BEGIN and END.

awk '/^BEGIN$/ { wantthis = 1; next }
/^END$/ { wantthis = 0; next }
{ if(wantthis) print $0 }'

The test for BEGIN can be augmented to spit out a dividing line of
some sort, if that's desired. Note that the line beginning with '{'
matches ALL lines.

I must confess that I programmed in C on UNIX systems for 11 years
before finally learning awk.  Should have gotten into it far sooner.
Awk is a tremendous tool, once you figure out how to use it.  (It's
a bit like pointers in C: one day it suddenly clicks.)

David Sherman
The Law Society of Upper Canada
Toronto
-- 
{ uunet!mnetor  pyramid!utai  decvax!utcsri  ihnp4!utzoo } !lsuc!dave



More information about the Comp.unix.wizards mailing list