Wednesday, April 22, 2009

awk script to add up lines in a file

You want to add up the numbers in a file?

Input:

56168
796
44
26
202
258
478
632

Script:

cat file | awk '{ total = total + $1} END { print total}'