Hi
I wonder if anyone can offer any help on this. I'm trying to manipulate some text from a file using a korn shell script.
I have the following data in a text file:
------------------------
C, HEADER1, BLAH, BLAH
R, HEADER2, BLAH, BLAH
C, HEADER1, BLAH, BLAH
R, HEADER2, BLAH, BLAH
C, HEADER1, BLAH, BLAH
R, HEADER2, BLAH, BLAH
P, IMPORTANT, DATA
P, MORE, IMPORTANT, DATA
C, HEADER1, BLAH, BLAH
R, HEADER2, BLAH, BLAH
-------------------------
I'd like to cut out only the section that contains the lines beginning with P,. But I need to include the HEADER1 and HEADER2 lines above that data. The other sections with only 2 lines (C, and R,) can be ignored.
Any ideas? I can't think of any way of using grep to get that section but ignore the others.
Cheers in advance
I wonder if anyone can offer any help on this. I'm trying to manipulate some text from a file using a korn shell script.
I have the following data in a text file:
------------------------
C, HEADER1, BLAH, BLAH
R, HEADER2, BLAH, BLAH
C, HEADER1, BLAH, BLAH
R, HEADER2, BLAH, BLAH
C, HEADER1, BLAH, BLAH
R, HEADER2, BLAH, BLAH
P, IMPORTANT, DATA
P, MORE, IMPORTANT, DATA
C, HEADER1, BLAH, BLAH
R, HEADER2, BLAH, BLAH
-------------------------
I'd like to cut out only the section that contains the lines beginning with P,. But I need to include the HEADER1 and HEADER2 lines above that data. The other sections with only 2 lines (C, and R,) can be ignored.
Any ideas? I can't think of any way of using grep to get that section but ignore the others.
Cheers in advance