Created
January 24, 2011 03:03
-
-
Save neilkod/792758 to your computer and use it in GitHub Desktop.
simple word count using awk
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
Tamara-Kodners-MacBook-Pro:tmp tamara$ cat coins.txt | |
gold 1 1986 USA American Eagle | |
gold 1 1908 Austria-Hungary Franz Josef 100 Korona | |
silver 10 1981 USA ingot | |
gold 1 1984 Switzerland ingot | |
gold 1 1979 RSA Krugerrand | |
gold 0.5 1981 RSA Krugerrand | |
gold 0.1 1986 PRC Panda | |
silver 1 1986 USA Liberty dollar | |
gold 0.25 1986 USA Liberty 5-dollar piece | |
silver 0.5 1986 USA Liberty 50-cent piece | |
silver 1 1987 USA Constitution dollar | |
gold 0.25 1987 USA Constitution 5-dollar piece | |
gold 1 1988 Canada Maple Leaf | |
Tamara-Kodners-MacBook-Pro:tmp tamara$ awk '{c=split($0, s); for(n=1; n<=c; ++n) print s[n] }' $1 coins.txt |sort|uniq -c|sort -nr | |
9 gold | |
7 USA | |
7 1 | |
5 1986 | |
4 silver | |
3 piece | |
3 Liberty | |
2 ingot | |
2 dollar | |
2 RSA | |
2 Krugerrand | |
2 Constitution | |
2 5-dollar | |
2 1987 | |
2 1981 | |
2 0.5 | |
2 0.25 | |
1 Switzerland | |
1 Panda | |
1 PRC | |
1 Maple | |
1 Leaf | |
1 Korona | |
1 Josef | |
1 Franz | |
1 Eagle | |
1 Canada | |
1 Austria-Hungary | |
1 American | |
1 50-cent | |
1 1988 | |
1 1984 | |
1 1979 | |
1 1908 | |
1 100 | |
1 10 | |
1 0.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment