最近在学ruby,发现某处提到linux的过滤器,挺有意思的.例子是这样的:将英文文本中出现最多的10个单词进行输出.
命令如下,使用到管道:
cat hoge.txt | tr -s ' ' '\n'| sort | uniq -c |sort -rn |head -n 10
notes:修改10为其他数字可以实现输出最多的n个单词
最近在学ruby,发现某处提到linux的过滤器,挺有意思的.例子是这样的:将英文文本中出现最多的10个单词进行输出.
命令如下,使用到管道:
cat hoge.txt | tr -s ' ' '\n'| sort | uniq -c |sort -rn |head -n 10
notes:修改10为其他数字可以实现输出最多的n个单词
转载于:https://my.oschina.net/timlentse/blog/337125