Xref: utzoo comp.unix.questions:6863 comp.unix.wizards:8247 Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!necntc!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: A little help with SED please Message-ID: <88@lakart.UUCP> Date: 4 May 88 14:41:54 GMT References: <762@pttesac.UUCP> Distribution: na Organization: Lake - The systems people Lines: 37 From article <762@pttesac.UUCP>, by robert@pttesac.UUCP (Robert Rodriguez): > In article <1988Apr26.011145.27914@lsuc.uucp> dave@lsuc.UUCP (David Sherman) writes: >>murillo@boulder.Colorado.EDU (Rodrigo Murillo) writes: >>>I need an sed line (or some gory pipeline) to extract the data between >>>BEGIN and END. >>[more stuff on "awk" deleted] > > I'm surprised nobody mentioned csplit. It's perfect for this stuff, > as the man page says, csplit is a context splitter. > > csplit -s -k foo /BEGIN/+1 /END/-1 May work, but csplit is nowhere to be found on our system (BSD 4.3). Seriously though, the following awk script does nicely, although it may need a bit of work if there is more than one field on a line: --- snip snip snippety snip --- snip snip snippety snip --- { if ($1 == "BEGIN") { state = 1 } else if ($1 == "END") { state = 0 } else if (state == 1) { print $1 } } --- snip snip snippety snip --- snip snip snippety snip --- -- dg@lakart.UUCP - David Goodenough +---+ | +-+-+ ....... !harvard!adelie!cfisun!lakart!dg +-+-+ | +---+