# No need perl. # For numbers all by their lonesome on a line. awk 'BEGIN { sum = 0 } END { print sum } { sum += $1 }' in > out