Created
October 7, 2021 10:20
-
-
Save falsycat/8ed6d97b2172677a57a075ea0021969b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
! /^(#|$)/ { | |
delete io | |
for (i = 4; i <= NF; ++i) { | |
split($i, tok, ":") | |
target = tok[1] | |
value = int(tok[2]) | |
io[target] = value | |
sum[target] += value | |
} | |
} | |
END { | |
targets_ = "money|wmcard|ALL" | |
split(targets_, targets, "|") | |
all=0 | |
for (i in targets) { | |
all += sum[targets[i]] | |
} | |
sum["ALL"] = all | |
for (i in targets) { | |
klen = length(targets[i]) | |
vlen = 6 # length(sum[targets[i]]) | |
w[i] = klen < vlen? vlen: klen; | |
} | |
for (i in targets) printf " %*s |", w[i], targets[i] | |
print "" | |
for (i in targets) printf " %*d |", w[i], sum[targets[i]] | |
print "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment