zoukankan      html  css  js  c++  java
  • SHELL日志分析 实例一

    要求:

    将该文件中的域名截取出来,统计重复域名出现的次数,然后按次数进行降序排列

    [root@tyzZ SHELL]# cat file 
    http://www.linuxidc.com/index.html
    http://www.google.com/index.html
    http://www.linuxidc.com/get.html
    http://www.linuxidc.com/set.html
    http://www.google.com/index.html
    http://www.yahoo.com.cn/put.html

    第一步 先截取域名

    [root@tyzZ SHELL]# awk -F"/" '{print $3}' file
    www.linuxidc.com
    www.google.com
    www.linuxidc.com
    www.linuxidc.com
    www.google.com
    www.yahoo.com.cn

    第二步 排序

    [root@tyzZ SHELL]# awk -F"/" '{print $3}' file |sort
    www.google.com
    www.google.com
    www.linuxidc.com
    www.linuxidc.com
    www.linuxidc.com
    www.yahoo.com.cn
    [root@tyzZ SHELL]# awk -F"/" '{print $3}' file |sort|uniq -c
          2 www.google.com
          3 www.linuxidc.com
          1 www.yahoo.com.cn
    [root@tyzZ SHELL]# awk -F"/" '{print $3}' file |sort|uniq -c|sort -frn
          3 www.linuxidc.com
          2 www.google.com
          1 www.yahoo.com.cn
    
  • 相关阅读:
    n的阶乘
    二叉树遍历
    二分查找练习
    字符串中最长回文序列求解
    复数集合
    AppCrawler自动化遍历使用详解(版本2.1.0 )(转)
    谷歌驱动下载链接
    谷歌浏览器插件
    Pycharm破解方法
    go学习链接
  • 原文地址:https://www.cnblogs.com/aallenn/p/6700605.html
Copyright © 2011-2022 走看看