【问题标题】:How to get uniq report with the below access log如何使用以下访问日志获取 uniq 报告
【发布时间】:2015-08-07 21:27:53
【问题描述】:

输入

Severity: Warning   Missing argument 1 for Pxxer_rzxczt_v3::mast() /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 115/dadm/index.php/plasdasd/mast/  
Severity: Warning   Missing argument 1 for Pxxer_rzxczt_v3::mast() /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 115/dadm/index.php/plasdasd/mast/  
Severity: Warning   Missing argument 1 for Pxxer_rzxczt_v3::mast() /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 115/dadm/index.php/plasdasd/mast/  
Severity: Notice   Undefined variable: vedwe erwer rew  /sdfdsfv/ddw/hdd/nddd/system/adsdn/wefwf/efe/codsds/pr_rt_v3.php 130/dadm/index.php/plasdasd/mast/  
Severity: Notice   Undefined variable: vedwe erwer rew  /sdfdsfv/ddw/hdd/nddd/system/adsdn/wefwf/efe/codsds/pr_rt_v3.php 130/dadm/index.php/plasdasd/mast/  
Severity: Notice   Undefined variable: vCode /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 130/dadm/index.php/plasdasd/mast/  
Severity: Notice   Undefined variable: vCode /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 130/dadm/index.php/plasdasd/mast/  
Severity: Notice   Undefined variable: vCode /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 130/dadm/index.php/plasdasd/mast/  

输出

Severity: Warning   Missing argument 1 for Pxxer_rzxczt_v3::mast() /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 115  - 3  
Severity: Notice   Undefined variable: vCode /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 130   -  3   
Severity: Notice   Undefined variable: vedwe erwer rew  /sdfdsfv/ddw/hdd/nddd/system/adsdn/wefwf/efe/codsds/pr_rt_v3.php 130   -  2  

【问题讨论】:

  • 您可能对man uniq感兴趣。
  • uniq 或排序任何东西都可以。
  • 只做sort input.txt | uniq
  • 请注意您是在与人类交谈。输入、输出不足以与人类交流。在这里学习如何行事!

标签: awk sed grep cut


【解决方案1】:

uniq unix 命令使用 -c 选项执行您想要的操作。

cat yourlog | uniq -c 将输出

   1 everity: Warning   Missing argument 1 for Pxxer_rzxczt_v3::mast() /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 115/dadm/index.php/plasdasd/mast/  
   2 Severity: Warning   Missing argument 1 for Pxxer_rzxczt_v3::mast() /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 115/dadm/index.php/plasdasd/mast/  
   2 Severity: Notice   Undefined variable: vedwe erwer rew  /sdfdsfv/ddw/hdd/nddd/system/adsdn/wefwf/efe/codsds/pr_rt_v3.php 130/dadm/index.php/plasdasd/mast/  
   3 Severity: Notice   Undefined variable: vCode /sdfdsfv/ddw/hdd/nddd/system/adsdn/codsds/pr_rt_v3.php 130/dadm/index.php/plasdasd/mast/  

但是,这将使不直接重复的重复行在不同的行上进行计数。

例如输入:

foo
foo
bar
bar
foo
foo

将给出输出:

2 foo
2 bar
2 foo

如果你希望输出是

2 bar
4 foo

您首先必须对文件进行排序,如下所示:

cat yourlog | sort | uniq -c

【讨论】:

    猜你喜欢
    • 2018-01-13
    • 1970-01-01
    • 1970-01-01
    • 2015-10-26
    • 1970-01-01
    • 2022-10-25
    • 2011-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多