I want to use 'awk' to extract specific information from a formatted file such that:
- If the row has 2 fields, the first column (100) is printed and the second column (2) represents "X" pairs of lines that follow
- If the row corresponding to NR + (2*X -1) starts with a "B" the second column of that row is printed
- If the corresponding row to NR + (2*X -1) does not start with a "B" the value "0" is printed.
Example File:
100 2
A .5 .4
.3 .2 .1
B .9 .8
.7 .6 .65
200 1
A .5 .4
.3 .2 .1
Ideal Output:
100 .9
200 0
Code Thus Far:
awk '{if(NF==2) print $1;}'
Which produces:
100
200