I would like to move a line of text to the end of the line below, and replicate the value moved for x lines, until a new match for the pattern is found. All the other text processing for my files I have figured out, but this copy and paste between patterns has me stumped.
Is this achievable with AWK/sed/grep? I cannot use csplit because the actual files are quite large, and so would fill up the disk very fast.
Thanks!
For an example: I have the following text file:
Voting Round 0
Ag_1 || 1 || 0 || 1 |
Ag_2 || 1 || 1 || 0 |
Ag_2 || 1 || 1 || 0 |
Ag_11 || 1 || 1 || 0 |
Voting Round 1
Ag_1 || 1 || 1 || 0 |
Ag_1 || 1 || 1 || 0 |
Ag_1 || 1 || 1 || 0 |
Ag_1 || 1 || 1 || 0 |
Voting Round 2
Ag_1 || 1 || 0 || 1 |
Ag_1 || 1 || 1 || 0 |
Ag_1 || 1 || 1 || 0 |
Ag_1 || 1 || 1 || 0 |
Voting Round 3
Ag_1 || 1 || 0 || 1 |
Ag_11 || 1 || 1 || 0 |
Ag_1 || 1 || 1 || 0 |
Ag_1 || 1 || 1 || 0 |
and I would like to generate something like this:
Ag_1 || 1 || 0 || 1 | 0
Ag_2 || 1 || 1 || 0 | 0
Ag_2 || 1 || 1 || 0 | 0
Ag_11 || 1 || 1 || 0 | 0
Ag_1 || 1 || 1 || 0 | 1
Ag_1 || 1 || 1 || 0 | 1
Ag_1 || 1 || 1 || 0 | 1
Ag_1 || 1 || 1 || 0 | 1
Ag_1 || 1 || 0 || 1 | 2
Ag_1 || 1 || 1 || 0 | 2
Ag_1 || 1 || 1 || 0 | 2
Ag_1 || 1 || 1 || 0 | 2
Ag_1 || 1 || 0 || 1 | 3
Ag_11 || 1 || 1 || 0 | 3
Ag_1 || 1 || 1 || 0 | 3
Ag_1 || 1 || 1 || 0 | 3