awk '{sum+=$1} END{print sum}' file.txt

Category: Text Processing

awk '{sum+=$1} END{print sum}' file.txt

Sum values in the first column

Adds up all the values in the first column and prints the total at the END of processing. END is an awk block that runs after all lines.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.