Xref: utzoo comp.unix.questions:6888 comp.unix.wizards:8298 Path: utzoo!mnetor!uunet!lll-winken!lll-tis!mordor!sri-spam!sri-unix!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: A little help with SED please Message-ID: <935@cresswell.quintus.UUCP> Date: 6 May 88 02:42:00 GMT References: <762@pttesac.UUCP> <88@lakart.UUCP> Distribution: na Organization: Quintus Computer Systems, Mountain View, CA Lines: 38 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 There is a very good reason why nobody mentioned csplit: it doesn't do the job. The original poster had a file junk0 BEGIN data1 END junk1 ... junkn BEGIN datan END junk and wanted all the "data" segments. When the csplit command is corrected to end with /END/ rather than /END/-1, it will create three files: xx00: junk0 BEGIN xx01: data1 xx02: END junk1 ... END junk This is not at all what was wanted! csplit has some rather unpleasant restrictions, like not being able to create more than 99 (or is it 100? the manual page is unclear) output files.