And it sux.
Take this eg. ...
% echo '4001966552\n4001966552' | mawk '{sum+=$1; print $1 ", " sum}END{print sum; printf "%lu\n", sum}'
4001966552, 4.00197e+09
4001966552, 8.00393e+09
8.00393e+09
2147483647
It seems that Mawk is not capable of printing integer numbers larger than 2147483647.
I could not find any hint on what might be the reason for this, Google only spit out
this original-mawk bug report. It contains some Mawk version information:
% ~/x/awk-build/mawk/build/awk/mawk -Wversion
mawk 1.3.4 20141206
Copyright 2008-2013,2014, Thomas E. Dickey
Copyright 1991-1996,2014, Michael D. Brennan
random-funcs: srandom/random
regex-funcs: internal
compiled limits:
sprintf buffer 8192
maximum-integer 2147483647
% /usr/bin/mawk -Wversion
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan
compiled limits:
max NF 32767
sprintf buffer 2040
If I run the same, I get the latter ... i.e. mawk in Ubuntu 14.0.4 is still v1.3.3 (package version is: 1.3.3-17ubuntu2).
Looking through the package sources of Mawk 1.3.3-17ubuntu2 (for the string "integer") I could not find any hint on the 2147483647 limit.
If you run the same example in Gawk, you get what you expect:
% echo '4001966552\n4001966552' | gawk '{sum+=$1; print $1 ", " sum}END{print sum; printf "%lu\n", sum}'
4001966552, 4001966552
4001966552, 8003933104
8003933104
8003933104
So stick with Gawk.
P.S.: I don't think that Mawk was the default Awk interpreter in Ubuntu. And this change most probabaly broke tons of Awk scripts (that relied on Gawk features not even knowing that those features were Gawk specific).
Recent comments
1 year 39 weeks ago
3 years 8 weeks ago
3 years 8 weeks ago
3 years 10 weeks ago
3 years 11 weeks ago
3 years 18 weeks ago
3 years 18 weeks ago
3 years 18 weeks ago
3 years 18 weeks ago
3 years 19 weeks ago