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
    
  • 相关阅读:
    Python学习4
    Python学习3
    Python学习2
    表空间
    sqlplus常用设置
    HashMap和LinkedHashMap
    堆栈源码
    观察者模式
    策略模式
    java线性表
  • 原文地址:https://www.cnblogs.com/tyzZ001/p/5958834.html
Copyright © 2011-2022 走看看