[PLUG] Adding numbers
Russell Senior
seniorr at aracnet.com
Thu Jan 29 12:35:02 UTC 2004
>>>>> "Felix" == Felix Lee <felix.1 at canids.net> writes:
Russell> That'll work, but the BEGIN clause is superfluous. Variables
Russell> default to zero anyway, so it can reduce to: $ awk '/missing/
Russell> { total += $7 } END { print total }' messages*
Felix> no, variables default to null. if no lines match, then your
Felix> version prints a blank line instead of 0.
Ah, yeah. In 15 years of awk use, that distinction has never bitten
me, but then the majority of my usage is ad hoc command-line stuff
where I am intelligent enough (but only just) to disambiguate. In a
script, where something else is depending on a number, the distinction
would be more important.
Thank you for the correction!
--
Russell Senior ``I have nine fingers; you have ten.''
seniorr at aracnet.com
More information about the PLUG
mailing list