How can I quickly sum all numbers in a file?

Posted by Mark Roberts on Stack Overflow See other posts from Stack Overflow or by Mark Roberts
Published on 2010-04-23T23:36:12Z Indexed on 2010/04/24 0:03 UTC
Read the original article Hit count: 202

Filed under:
|
|
|
|

I have a file which contains several thousand numbers, each on it's own line:

34
42
11
6
2
99
...

I'm looking to write a script which will print the sum of all numbers in the file. I've got a solution, but it's not very efficient. (It takes several minutes to run.) I'm looking for a more efficient solution. Any suggestions?

© Stack Overflow or respective owner

Related posts about shell-scripting

Related posts about bash