I'm trying to print the value corresponding to the words A, B, C, D, E. These words could appear sometimes and sometimes not inside each group of lines. Each group of lines begins with "ZYX".
My issue with current code is that should print values for 3 groups and only is printing for 2 groups (group 1 and group 3) and I'm not sure why.
What is missing in my current code to fix this?
The current output is:
123|3|22|56|881
711||988||444
and desired ouput:
123|3|22|56|881
332|453|11||
711||988||444
My input file is:
ZYX
A = 123
B = 3
C = 22
D = 56
E = 881
ZYX
A = 332
B = 453
C = 11
ZYX
A = 711
C = 988
E = 444
It prints when E is met. If there is no E nothing is printed.
Instead it must print at the end of each block, that is either when ZYX is met or at the END, and if it's not line 1.
Consider a
function prt() {if (NR>1) print a"|"b"|"c"|"d"|"e}
When a header is found, all of the data fields are cleared (i.e., set to empty strings) by the above statement.
The individual data fields are filled in as they are found by the statements on the following lines in the script. All of the fields have to be cleared so data from an earlier header isn't printed as data from a later header that did not contain entries for some fields.