问题
Input
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/
Output
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
回答1:
The uniq unix command does what you want, with the -c option.
cat yourlog | uniq -c
will output
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/
This will however make repeated lines that are not directly repeated after each other to be counted up on different lines.
For example the input:
foo
foo
bar
bar
foo
foo
will give the output:
2 foo
2 bar
2 foo
If you want the output to be
2 bar
4 foo
you would first have to sort the file, like this:
cat yourlog | sort | uniq -c
来源:https://stackoverflow.com/questions/30454601/how-to-get-uniq-report-with-the-below-access-log