Sum a Column With awk

Aggregate numbers in a column without a spreadsheet.

LinuxtextstatsscriptingcliLow risk
Run awk '{s+=$1} END {print s}' file to add up the first column.

01Command

Command
$ awk '{s+=$1} END {print s}' numbers.txt

02What it does

awk splits each line into fields and accumulates a running total in END, so summing, averaging or counting a column of a text file is a one-liner that scales to millions of rows. It is scriptable in a way that a GUI spreadsheet is not.

03Risk

RiskLow risk
RequirementsPreinstalled on Linux (GNU awk)
!Warning: awk treats non-numeric fields as zero; clean the input or validate columns first if data is mixed.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-10-13 · Category: Developer

06Related solutions