Hi,
I have a file that has numerous lines separated by a unique
header and I want to parse out into individual files based on that header. Here's the example file:
HDR1 SDFSDF SDFSDFSDFSDFSDFSDF
HDR2 SDFSDFSDFSDFSDFSDFSDF
DATA
DATA
DATA
HDR1 SDFSDF SDFSDFSDFSDFSDF
HDR2 SDFSDFSDFSDFSDFSDFSDFF
DATA
DATA
DATA
Here's what I am trying to do. When the script finds an index substring of HDR1 it writes each block of records to a
sequential file named 1.dat
When it finds the next occurance of HDR1 it will then write that group to a file named 2.dat and so on to bottom of file.
I also have a need to adapt this similar script where the second field of the HDR1 record would be the filename.dat for each group of data. I can't use it on this particular data file because the description of field 2 has embedded spaces - so if you can help on the first method, I would be very gratful.
Thanks for the help.
I have a file that has numerous lines separated by a unique
header and I want to parse out into individual files based on that header. Here's the example file:
HDR1 SDFSDF SDFSDFSDFSDFSDFSDF
HDR2 SDFSDFSDFSDFSDFSDFSDF
DATA
DATA
DATA
HDR1 SDFSDF SDFSDFSDFSDFSDF
HDR2 SDFSDFSDFSDFSDFSDFSDFF
DATA
DATA
DATA
Here's what I am trying to do. When the script finds an index substring of HDR1 it writes each block of records to a
sequential file named 1.dat
When it finds the next occurance of HDR1 it will then write that group to a file named 2.dat and so on to bottom of file.
I also have a need to adapt this similar script where the second field of the HDR1 record would be the filename.dat for each group of data. I can't use it on this particular data file because the description of field 2 has embedded spaces - so if you can help on the first method, I would be very gratful.
Thanks for the help.