Dear members,
I have a text file with several lines of output as below.
Each header line has HEADER number and word PRINT.
I will need to grep the first word in the line with the keyword PRINT i.e HEADER1, HEADER2 and basically prefix as column1 in each line underneath. Should do this until the next PRINT is found, this marks the end of that dataset and so on.... Can you please suggest a way/command to achieve this ?
Source file :
HEADER1 PRINT
text1_1 text2_1 text3_1
text1_1 text2_1 text3_1
text1_1 text2_1 text3_1
HEADER2 PRINT
text1_2 text2_2 text3_2
text1_2 text2_2 text3_2
text1_2 text2_2 text3_2
HEADER3 PRINT
text1_3 text2_3 text3_3
text1_3 text2_3 text3_3
text1_3 text2_3 text3_3
Necessary Output :
HEADER1 text1_1 text2_1 text3_1
HEADER1 text1_1 text2_1 text3_1
HEADER1 text1_1 text2_1 text3_1
HEADER2 text1_2 text2_2 text3_2
HEADER2 text1_2 text2_2 text3_2
HEADER2 text1_2 text2_2 text3_2
HEADER3 text1_3 text2_3 text3_3
HEADER3 text1_3 text2_3 text3_3
HEADER3 text1_3 text2_3 text3_3
Best Regards.
I have a text file with several lines of output as below.
Each header line has HEADER number and word PRINT.
I will need to grep the first word in the line with the keyword PRINT i.e HEADER1, HEADER2 and basically prefix as column1 in each line underneath. Should do this until the next PRINT is found, this marks the end of that dataset and so on.... Can you please suggest a way/command to achieve this ?
Source file :
HEADER1 PRINT
text1_1 text2_1 text3_1
text1_1 text2_1 text3_1
text1_1 text2_1 text3_1
HEADER2 PRINT
text1_2 text2_2 text3_2
text1_2 text2_2 text3_2
text1_2 text2_2 text3_2
HEADER3 PRINT
text1_3 text2_3 text3_3
text1_3 text2_3 text3_3
text1_3 text2_3 text3_3
Necessary Output :
HEADER1 text1_1 text2_1 text3_1
HEADER1 text1_1 text2_1 text3_1
HEADER1 text1_1 text2_1 text3_1
HEADER2 text1_2 text2_2 text3_2
HEADER2 text1_2 text2_2 text3_2
HEADER2 text1_2 text2_2 text3_2
HEADER3 text1_3 text2_3 text3_3
HEADER3 text1_3 text2_3 text3_3
HEADER3 text1_3 text2_3 text3_3
Best Regards.