diff options
Diffstat (limited to 'sum2.awk')
| -rw-r--r-- | sum2.awk | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -3,7 +3,9 @@ ### sum2.awk, print column sums # check that each line has the same number of fields as line one -NR==1 { nf_max = NF } +BEGIN { OFS = FS } + +NR == 1 { nf_max = NF } { for (i=1; i<=NF; i++) @@ -13,6 +15,6 @@ NR==1 { nf_max = NF } } END { - for (i=1; i<=NF; i++) + for (i=1; i<=nf_max; i++) printf(OFMT "%s", sum[i], i < nf_max ? OFS : ORS) } |
