Hello, maybe someone could help me with this.
I'm trying to print in a more ordered way this input.
the input file is:
AB XY UT ZW PRAT
0 3 4 7214800 93
0 3 4 730770 93
VLL VMI VKO VER
39 5
0 1 4 7318 93
0 2 4 87477 187
VLL VMI VKO VER
102 7 0-0
0 9 4 49365 185
0 1 4 5307 93
For some lines there are 2 related lines that contain "VLL VMI VKO VER" and in next line a corresponding value.
For example:
- The line where $4=730770 (header is ZW), has the value VLL=39 and VKO=5
- The line where $4=87477 has the value VLL=102, VMI=7 and VER=0-0
So, I would like to print this related values in the sale line when happens.
The output I'm looking for is like this:
AB XY UT ZW PRAT VLL VMI VKO VER
0 3 4 7214800 93
0 3 4 730770 93 39 5
0 1 4 7318 93
0 2 4 87477 187 102 7 0-0
0 9 4 49365 185
0 1 4 5307 93
I've was able to get this awk script but is far from desired output since basically is removing the lines with "VLL VMI VKO VER" and leaving the values in same place (in next line).
awk 'BEGIN{print "AB XY UT ZW PRAT VLL VMI VKO VER"}
NR>1 && $0!~"VLL" {print}
/VLL VMI VKO VER/{getline v; print v}' inputfile
AB XY UT ZW PRAT VLL VMI VKO VER
0 3 4 7214800 93
0 3 4 730770 93
39 5
0 1 4 7318 93
0 2 4 87477 187
102 7 0-0
0 9 4 49365 185
0 1 4 5307 93
Thanks in advance