A little help with SED please
Richard A. O'Keefe
ok at quintus.UUCP
Fri May 6 12:42:00 AEST 1988
>From article <762 at pttesac.UUCP>, by robert at pttesac.UUCP (Robert Rodriguez):
> In article <1988Apr26.011145.27914 at lsuc.uucp> dave at lsuc.UUCP (David Sherman) writes:
>>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.
>>[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.
More information about the Comp.unix.wizards
mailing list