Last active
April 12, 2018 00:55
-
-
Save greymd/079c4964f04ab03003f35c7e5a9c8dc1 to your computer and use it in GitHub Desktop.
sum digits in the line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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