diff options
| author | wukong <wukong@longaeva> | 2026-05-03 13:10:31 -0700 |
|---|---|---|
| committer | wukong <wukong@longaeva> | 2026-05-03 13:10:31 -0700 |
| commit | b60f09401a15721f626bcb7c852f68b82fe39c1c (patch) | |
| tree | 0fa5ed72ec96c8b0cc83699a0497761c9ec0eed7 /sum4.awk | |
| parent | e3f9ccd5303c516d2e1c48112d8b52609ce4ad5e (diff) | |
replaced sum[1-4].awk with serial and columnar versions;
minor merge updates between fir_window scripts;
Diffstat (limited to '')
| -rw-r--r-- | sum4.awk | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/sum4.awk b/sum4.awk deleted file mode 100644 index 3e61843..0000000 --- a/sum4.awk +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/awk -f - -### sum4.awk, print sums of numeric columns -# input: rows of integers and strings -# output: sums of numeric columns - - -function isnum(n) { - sign = "[+-]?" - decimal = "[0-9]+[.]?[0-9]*" - fraction = "[.][0-9]+" - exponent = "([Ee]" sign "[0-9]+)?" - number = "^" sign "(" decimal "|" fraction ")" exponent "$" - return n ~ number -} - - -BEGIN { - OFS = FS -} - - -NR == 1 { - for (i=1; i<=NF; i++) - isnum($i) ? header[i] = "col" i : header[i] = $i -} - - -NF > 0 { - (NF > nf_max) ? nf_max = NF : nf_max = nf_max - for (i=1; i<=NF; i++) { - if ($i == header[i]) - continue - if (isnum($i)) { - count[i]++ - sum[i] += $i - } - } -} - - -END { - for (i=1; i<=nf_max; i++) { - printf((header[i]) ? header[i] OFS : OFS) - printf((count[i]) ? count[i] OFS sum[i] : OFS) - printf(ORS) - } -} - |
