diff options
Diffstat (limited to '')
| -rw-r--r-- | sum3.awk | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/sum3.awk b/sum3.awk deleted file mode 100644 index 7f11a49..0000000 --- a/sum3.awk +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/awk -f - -### sum3.awk, print sums of numeric columns -# input: rows of integers and strings -# output: sums of numeric columns -# assumes every line has same layout - - -function isnum(n) { - return n ~ /^[+-]?[0-9]+$/ -} - - -BEGIN { - OFS = FS -} - - -NR == 1 { - for (i=1; i<=NF; i++) - numcol[i] = isnum($i) -} - - -NF > 0 { - (NF > nf_max) ? nf_max = NF : nf_max = nf_max - for (i=1; i<=NF; i++) - if (numcol[i]) - sum[i] += $i -} - - -END { - for (i=1; i<=nf_max; i++) { - printf(numcol[i] ? sum[i] : "--") - printf(i < nf_max ? OFS : ORS) - } -} - |
