Created
May 10, 2017 01:42
-
-
Save kilfu0701/25b6a25f2f001a34515c6e6604ab1d9e to your computer and use it in GitHub Desktop.
My AWK commands
This file contains hidden or 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
| ### Calculate total sum for prices in a file | |
| # file content sample: | |
| #I, [2017-05-09T23:50:19.364803 #19144] INFO -- : 32:userA の売上集計をしました(2880円) | |
| #I, [2017-05-09T23:50:20.212623 #19144] INFO -- : 33:userB は売上がないので飛ばしました | |
| #I, [2017-05-09T23:50:27.657490 #19144] INFO -- : 51:userC の売上集計をしました(175738円) | |
| grep -r "円" sales.log-20170510 | gawk 'match($0, /.*\((.*)円\)$/, a) {print a[1]}' | awk '{ sum += $1 } END { print sum }' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment