$ awk 'NF > m { m = NF } { s += NF } END { printf("Max = %d\nAvg = %g\n", m, s/NR) }' data.in
Max = 9
Avg = 3.33333
The awk script will keep track of the maximum number of fields (columns) in m and the sum of the number of fields in s. AtWhen reaching the end of the input stream, it will output the stats collected.
The number of fields in the current record (line) is NF, and the number of records read so far is NR.
The following version will also keep track of the record with the most number of fields:
awk 'NF > m { m = NF; r = NR } { s += NF } END { printf("Max = %d (%d)\nAvg = %g\n", m, r, s/NR) }' data.in
Max = 9 (6)
Avg = 3.33333