# Created on savesnippets.com ยท https://savesnippets.com/Uf6RGv1dGqwiGp # Sum the request-byte column (col 10) from an nginx access log awk '{ s += $10 } END { print s }' access.log # Sum a column from a CSV (-F sets the field separator) awk -F, '{ s += $3 } END { print s }' transactions.csv # Average instead of sum awk '{ s += $1; n++ } END { print s/n }' numbers.txt # Sum grouped by column 2 (like SQL GROUP BY) awk -F, '{ by[$2] += $3 } END { for (k in by) print k, by[k] }' transactions.csv | sort -k2 -rn