分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
我们来看看a.txt文件:
taoge@localhost Desktop> cat a.txt1234561111456123123123taoge@localhost Desktop>
先对其排序(按串排序):
taoge@localhost Desktop> cat a.txt | sort1111112312312323456456taoge@localhost Desktop>
再进行聚合:
taoge@localhost Desktop> cat a.txt | sort | uniq -c 1 1 1 1111 3 123 1 2 1 3 2 456taoge@localhost Desktop>
聚合后得到频次, 最后对频次进行排序(r表示逆向排序, n表示按数值排序, k表示按第k列进行排序):
taoge@localhost Desktop> cat a.txt |sort | uniq -c | sort -rnk 1 3 123 2 456 1 3 1 2 1 1111 1 1taoge@localhost Desktop>
爽爽哒。 在后台开发中, 经常要涉及到数据统计, 如上命令真是利器啊!
给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/2e19ffb3303a490d20ea5d00dd397156.gif)