Bash command to calculate average on each row and each column
问题 Suppose we have a log file like marks.log and the content looks something like this: Fname Lname Net Algo Jack Miller 15 20 John Compton 12 20 Susan Wilson 13 19 I want to add a new column that contains average for each person, and a new row that contains average for each course. The result has to look like this: Fname Lname Net Algo Avg Jack Miller 15 20 17.5 John Compton 12 20 16 Susan Wilson 13 19 16 Average 13.3 19.6 - 回答1: If your data is in datafile.txt , the syntax for awk could be