Hi I'm new to this forum and I'm a beginner when it comes to shell and awk programming. But I have the following problem:
I have 5 csv files (data1.csv, data2.csv, etc.) and need to calculate the average between the total sum of the 1st and 7 column.
csv example:
0055,1011,0000,1012,20081012,0,0,5,5,0,
0023,1011,8005,1012,20081012,3,24.94,49,351,0,
0095,1011,0000,1012,20081012,0,4.25,4,0,0,
I can get the sum by running a for loop to calculate the total
for f in `ls data*`; do cat $f | awk -F "," 'BEGIN { rsum = 0 } { rsum += $7 } END { print rsum }' >> avg.csv ; done
Is a simple and clean way to have awk sum the total, then find the average between them?