Operating System - HP-UX
1752277 Members
4676 Online
108786 Solutions
New Discussion

Re: Awk problem - addition?

 
SOLVED
Go to solution
James R. Ferguson
Acclaimed Contributor

Re: Awk problem - addition?

Hi:

> thanks everyone. You were all brilliant. To whom do I owe the points?

Points can be awarded to everyone as you see fit. There is no limit to the overall number that can be assigned. Please read :

http://forums12.itrc.hp.com/service/forums/helptips.do?#34

Regards!

...JRF...

TTr
Honored Contributor

Re: Awk problem - addition?

The awk program is using 32-bit arithmetic so the suming in awk overflows at 2147483647. (2^31 - 1). It does not error out, it keeps adding but the sum does not change once you reach the above number. At least it did it on my 11.11 workstation. I did not check if there are any patches for awk.

An alternative to adding with awk would be to use bc or dc. I did it using a "while read" loop, I don't know how to do it with inline bc commands. Maybe a bc expert can offer a quicker solution.

I also added a comment to your other posting about "ps -ef | awk"