First, there's a typo in your post since '^HEADER0001' doesn't match the actual lines that begin "HDRHEADER0001".
What defines the "section" that you want? If for "HDRHEADER0001" it's always just the next line, that's easy:
Code:
sed -n "/^HDRHEADER0001/,+1p" INPUT.TXT>OUTPUT.TXT
It it's everything up to but not including the next "HDRHEADER" line, that's going to be quite a bit more complicated. Yes,
sed can do it (its language is Turing-complete), but it might not be a suitable tool for the job. That task would be simple in
awk or
perl, but somewhat convoluted in
sed.