Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sum digits in the line
# https://unix.stackexchange.com/questions/205936/how-can-i-quickly-sum-all-numbers-in-a-file/205939
perl -pe 's/\d*/$s+=$&/ge}{$_=$s' file
perl -F= -pe '$s+=$F[1]}{print $s' file
awk -F= '{sum+=$2};END{print sum}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.