Xref: utzoo comp.unix.questions:6699 comp.unix.wizards:8026 Path: utzoo!mnetor!lsuc!dave From: dave@lsuc.uucp (David Sherman) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: A little help with SED please Message-ID: <1988Apr26.011145.27914@lsuc.uucp> Date: 26 Apr 88 05:11:42 GMT References: <5490@sigi.Colorado.EDU> Reply-To: dave@lsuc.UUCP (David Sherman) Distribution: na Organization: Law Society of Upper Canada, Toronto Lines: 22 Summary: use awk instead -- it's trivial murillo@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