Created
July 12, 2017 10:54
-
-
Save GitSumito/565a603534565d00a3f2df9634bb1dc7 to your computer and use it in GitHub Desktop.
アクセスログから任意のランキングを作る汎用的なワンライナー ref: http://qiita.com/S-T/items/73b2bb095c1b81e9337d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perl -ne 'next unless(/★単純にgrepするキーワード★/);/★集計単位★/;$counts{$1}++;END{for(sort keys %counts){print "$_ $counts{$_}\n"}}' access_log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ perl -ne 'next unless(/Googlebot/);/2017:(\d\d)/;$counts{$1}++;END{for(sort keys %counts){print "$_ $counts{$_}\n"}}' access_log | |
03 1 | |
04 11 | |
05 17 | |
06 36 | |
07 20 | |
08 36 | |
09 30 | |
10 33 | |
11 54 | |
12 45 | |
13 62 | |
14 23 | |
15 32 | |
16 38 | |
17 24 | |
18 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ perl -ne 'next unless(/Safari/);/2017:(\d\d)/;$counts{$1}++;END{for(sort keys %counts){print "$_ $counts{$_}\n"}}' access_log | |
03 89 | |
04 1982 | |
05 6149 | |
06 15110 | |
07 18474 | |
08 17452 | |
09 14082 | |
10 11929 | |
11 11365 | |
12 12830 | |
13 9830 | |
14 16637 | |
15 19439 | |
16 19432 | |
17 25928 | |
18 22898 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perl -ne 'next unless(/Googlebot/);/^(\S+)/;$counts{$1}++;END{for(sort keys %counts){print "$_ $counts{$_}\n"}}' access_log | |
66.249.66.205 1 | |
66.249.71.143 1 | |
66.249.71.145 2 | |
66.249.71.147 2 | |
66.249.71.73 182 | |
66.249.71.75 106 | |
66.249.71.76 1 | |
66.249.71.77 56 | |
66.249.71.77, 1 | |
66.249.71.78 1 | |
66.249.79.35 48 | |
66.249.79.39 25 | |
66.249.79.61 51 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ perl -ne 'next unless(//);/(\/js\/v2\/\w+)/;$counts{$1}++;END{for(sort keys %counts){print "$_ $counts{$_}\n"}}' access_log | |
95215 | |
/js/v2/com 19069 | |
/js/v2/fb 63491 | |
/js/v2/pc 27632 | |
/js/v2/old 26 | |
/js/v2/smartphone 9392 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
END{集計処理} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/★集計単位★/;$counts{$1}++; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment