排序一个网站的访问统计,并按照域名进行倒序排列,如:
http://www.selinux.com/a.html http://bbs.selinux.com/b.html http://nj.selinux.com/a.html http://www.selinux.com/ab.html http://sh.selinux.com/a.html http://bbs.selinux.com/a.html http://www.selinux.com/a.html http://www.selinux.com/a.html http://sh.selinux.com/a.html http://www.selinux.com/123.html http://book.bbs.selinux.com/a.html http://www.selinux.com/b.html
刚稍微写了简单的排序方法:
[root@fc16 ~]# time awk -F selinux '$1 ~/^http:\/\// {print $1}' test_word.txt |awk -F "//" '{print $2}'|sort|uniq -c |sort -rn|awk '{print $1" http://"$2"selinux.com"}' 6 http://www.selinux.com 2 http://sh.selinux.com 2 http://bbs.selinux.com 1 http://nj.selinux.com 1 http://book.bbs.selinux.com real 0m0.006s user 0m0.001s sys 0m0.010s
又感觉这样太麻烦,改了改:
[root@fc16 ~]# time awk -F '/' '$1 ~/^http/ {print $(NF-1)}' test_word.txt |sort |uniq -c|sort -rn 6 www.selinux.com 2 sh.selinux.com 2 bbs.selinux.com 1 nj.selinux.com 1 book.bbs.selinux.com real 0m0.007s user 0m0.001s sys 0m0.010s