Sum all numbers in a file

Uses awk to sum all the numbers in a file. This command is also resilient to big numbers since it internally converts each number to a string.

Authored by: devnull
Brought to you by Warp, a free terminal reimagined to work like a modern app.
file_name

Command
Copy
awk 'BEGIN {OFMT = "%.0f"} { sum += $1 } END { print sum }' file_name
Tags