A little help with SED please - cla
rjd at occrsh.ATT.COM
rjd at occrsh.ATT.COM
Thu Apr 21 04:16:00 AEST 1988
:I need an sed line (or some gory pipeline) to extract the data between
^^^^^^^^^^^^^^^^^^^^^^
:BEGIN and END.
:
:I should have added the following:
:
: >I have a text file of this form:
: [... junk ...]
: > BEGIN
: > 1
: > 2
: > 3
: > END
: [... junk ...]
: > BEGIN
: > 4
: > 5
: > 6
: > END
: [... junk ...]
Is "awk" gory enough??? :-) Here's an awk script:
cat <text file> | awk -f script
where 'script' is a file containing this:
--------- cut here ---------
BEGIN {
prnt=0
bgn=0
}
/BEGIN/ && $0 == "BEGIN" {prnt=1;bgn=1}
/END/ && $0 == "END" {prnt=0}
NF > 0 {
if( prnt == 1 && bgn != 1)
print $0
bgn=0
}
--------- cut here ---------
Randy
More information about the Comp.unix.wizards
mailing list