I have the following script that will average the last two fields of each row, but im not sure how to include the 3rd field of the following row.
An example of the analysis that I need to perform from the input -
(66.61+58.01+54.16)/3
awk '{sum=cnt=0; for (i=13;i<=NF;i++) { sum+=$i; cnt++ } { print $1, $2, sum/cnt } }' input
Input
01001 271895 53.71 48.74 67.64 76.39 81.90 89.22 91.06 90.37 90.91 75.99 66.61 58.01
01001 271896 54.16 60.85 65.32 81.61 88.54 88.16 92.03 94.50 90.75 77.18 69.87 58.69
01001 271897 54.18 63.10 71.44 75.06 83.16 95.63 93.34 89.89 88.88 81.32 68.14 58.77
01001 271898 60.55 59.13 70.97 71.98 89.51 93.87 91.47 88.79 86.67 73.62 61.66 55.71
Output
01001 271895 62.31
01001 271896 64.28
01001 271897 63.45
Desired Output
01001 271895 59.59
01001 271896 60.91
01001 271897 62.49
Any tips?