Created
February 12, 2015 12:03
-
-
Save kitsuyui/cd5482a8e0a1487eb864 to your computer and use it in GitHub Desktop.
awk で気軽に集計 ref: http://qiita.com/kitsuyui/items/3647bd5b8a5b3e858d3c
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
$ awk '{s += $1} END {print s}' < sample-1.txt | |
18 |
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
$ awk '{a += $1; b += $2} END {print a, b}' < sample-2.txt | |
10 26 |
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
$ sort -n < sample-3.txt | uniq -c | |
7 a | |
3 b | |
1 c |
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
$ sort -n < sample-3.txt | uniq -c | awk '{a+=$1; print $2, $1} END {print "計”, a}' | |
a 7 | |
b 3 | |
c 1 | |
計 11 |
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
3 | |
4 | |
5 | |
6 |
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
1 5 | |
2 6 | |
3 7 | |
4 8 |
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
a | |
a | |
a | |
a | |
a | |
a | |
a | |
b | |
b | |
b | |
c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment