Search This Blog

Monday, April 26, 2010

Cool ways of adding numbers in a text file in bash:

awk '{s+=$0} END {print s}' /tmp/file.txt

paste -sd+ /tmp/file.txt | bc

Source: http://unstableme.blogspot.com/2009/11/sum-of-numbers-in-file-unix.html

No comments:

Post a Comment