May-21-2024, 03:29 AM
I have a file with hundred of lines. They are grouped similar to the example below.
What would be the best approach to move or copy the line that starts with the string "aaaaaa" to the beginning of every line of its group ?
The group ends at the line before the next "aaaaaa".
Input file:
Desired output:
What would be the best approach to move or copy the line that starts with the string "aaaaaa" to the beginning of every line of its group ?
The group ends at the line before the next "aaaaaa".
Input file:
aaaaaa 1 bbbbbb ... zzzzzz aaaaaa 2 bbbbb ... zzzzzz
Desired output:
aaaaaa 1 aaaaaa 1 aaaaaa 1 bbbbbb aaaaaa 1 ... aaaaaa 1 zzzzzz aaaaaa 2 aaaaaa 2 aaaaaa 2 bbbbbb aaaaaa 2 ... aaaaaa 2 zzzzzz