# Calculate the average of a file full of line-separated numbers awk '{ sum += $2; n++ } END { if (n > 0) print sum / n; }'