# File : avg.awk # # Input : A file with a set of numbers. # Output : Takes the first number of each line, sums them together # and outputs them on a single line. The final number on the # line is the average of the values. # BEGIN{ total = 0; number = 0; } { number += 1; total += $1; printf("%6.2f ", $1); } END { printf(" %6.2f\n", total/number) }