[root@pangu icai]# cat words.txt
how many cans can a canner can if a canner can can cans
a canner can can as many cans as a canner can if a canner can can a can
a canner can can as many cans as a canner can cans
[root@pangu icai]# cat words.txt |tr ' ' '\n'|sort |uniq -c|sort -r
8 a
7 canner
5 cans
4 as
3 many
2 if
1 how
13 can
[root@pangu icai]# cat words.txt |tr ' ' '\n'|sort |uniq -c|sort -nr
13 can
8 a
7 canner
5 cans
4 as
3 many
2 if
1 how
關于解題:
https://discuss.leetcode.com/topic/87252/solve-this-problem-in-linux-style