Calculate the average, minimum and maximum of a column
awk average of a column | calculate average response time command line | find min and max value in column linux | awk | statistics | columnsawk -v c=2 'NR == 1 {min = max = $c} {s += $c; if ($c < min) min = $c; if ($c > max) max = $c} END {if (NR) printf "n=%d avg=%.2f min=%s max=%s\n", NR, s/NR, min, max}' measurements.txtReads the given column of each line, keeps track of the smallest and largest value and finally prints the count, the average with two decimal places, the minimum and the maximum. Suitable for measurement series, load times from logs or size lists. The file should contain data lines only.
Note: A header line skews the result, cut it off beforehand with tail -n +2 datei | awk ....
Also searched as
- awk average of a column
- calculate average response time command line
- find min and max value in column linux