### sum2.awk, print column sums # check that each line has the same number of fields as line one NR==1 { nfld = NF } { for (i=1; i<=NF; i++) sum[i] += $i if (NF != nfld) print "line " NR " has " NF " entries, not " nfld } END { for (i=1; i<=NF; i++) printf("%g%s", sum[i], i < nfld ? " " : "\n") }