如何使用下面的访问日志获取uniq报告



输入

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  

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

最新更新