linux命令使用 cut/sort/uniq

我记得之前去XX网面试的那个面试题是这样的:有个apache.log?文件文本内容如下:
======================
[niewj@centSvr?~]$?cat?apache.log?????????
http://www.163.com/1.html
http://www.sohu.com/index.html
http://www.sina.com/index.html
http://www.sohu.com/3.html
http://www.163.com/2.html
http://www.163.com/3.html
======================
要求统计出结果如下的内容:
======================
??????3?
www.163.com
??????1?
www.sina.com
??????2?
www.sohu.com
======================
我找到方法了,当初请教各位大神,各位给的awk/sed什么的,把我吓呆
了,我用cut/sort/uniq实现了:如下:一步一步看走:
===========================================================
[niewj@centSvr?~]$?cut?-d/?-f3?apache.log?
www.163.com
www.sohu.com
www.sina.com
www.sohu.com
www.163.com
www.163.com
[niewj@centSvr?~]$?cut?-d/?-f3?apache.log?|uniq?-c
??????1?
www.163.com
??????1?
www.sohu.com
??????1?
www.sina.com
??????1?
www.sohu.com
??????2?
www.163.com
[niewj@centSvr?~]$?cut?-d/?-f3?apache.log?|sort?|uniq?-c?
??????3?
www.163.com
??????1?
www.sina.com
??????2?
www.sohu.com

?

结果便出来了。好强大,学了都是自个的!!!

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。