We have the following file where a bunch of records (million records) of interest are between the start and end of patterns. The start pattern always start with an A and the end pattern always starts with a Z.
Apattern1 somethinghere #start of pattern always starts with A
Line-of-data-here-aaa
Line-of-data-here-xxxxx
Zpattern1 #end of pattern always starts with Z
ApatternX somethinghere #Repeat: start of pattern always starts with A
Line-of-data-here-bbbb
Line-of-data-here-yyyy
Line-of-data-here-nnnnn
ZpatternX
We Want to transform the data by appending the start pattern (entire line) to the lines within the pattern. We want to remove the end pattern. We want to use sed and/or awk to append the lines that start the pattern (starts with A) to the lines within the pattern (starts with L) and get rid of the end of the pattern (always starts with Z)So the data file would look like this:
Apattern1 somethinghere Line-of-data-here-aaa
Apattern1 somethinghere Line-of-data-here-xxxxx
ApatternX somethinghere Line-of-data-here-bbbb
ApatternX somethinghere Line-of-data-here-yyyy
ApatternX somethinghere Line-of-data-here-nnnnn