summaryrefslogtreecommitdiff
path: root/sum4.awk
diff options
context:
space:
mode:
authorwukong <wukong@longaeva>2018-06-13 21:41:39 -0700
committerwukong <wukong@longaeva>2018-06-13 21:41:39 -0700
commit8875b420a873a360a9484778b487394add318a5e (patch)
treed357816354c5d9d4bc3b1db5c43ceda7933b5e3f /sum4.awk
parent6bb6be845b6099550e0a530217633e30522093ad (diff)
added shebang, replaced if-elses with shortcut notation, ported online mean and variance calc to mean.awk
Diffstat (limited to '')
-rw-r--r--sum4.awk9
1 files changed, 5 insertions, 4 deletions
diff --git a/sum4.awk b/sum4.awk
index c592409..518f6e5 100644
--- a/sum4.awk
+++ b/sum4.awk
@@ -1,3 +1,5 @@
+#!/usr/bin/awk -f
+
### sum4.awk, print sums of numeric columns
# input: rows of integers and strings
# output: sums of numeric columns
@@ -12,7 +14,7 @@ function isnum(n) {
}
NR==1 {
- nfldz = NF
+ nf_max = NF
for (i=1; i<=NF; i++) {
if (!isnum($i))
header[i] = $i
@@ -27,11 +29,10 @@ NR==1 {
}
END {
- for (i=1; i<=nfldz; i++) {
+ for (i=1; i<=nf_max; i++) {
if (header[i])
printf("%s: \t", header[i])
- #if (numcol[i])
printf("%g\n", sum[i])
- printf(i < nfldz ? "" : "\n")
+ printf(i < nf_max ? "" : "\n")
}
}