Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Awk to Sum Columns

Simple sum

Consider this .csv file:

sample.csv
ID,AMOUNT
1,3.33
2,8.66

We can then use this Awk program to sum the amount column:

$ awk -F ',' '{ sum+=$2; } END { print sum; }'

And then feeding the file to the program:

$ awk -F ',' '{ sum+=$2; } END { print sum; }' ./sample.csv
11.99