Awk - UniqUrls
Examples - custom_filter.awk
file:awk/uniq_urls.awk #!/usr/bin/awk { if(NF==11) { if(index($8, "?")) { printf("%s %s\n", $7, $8); #printf("%s %s\n", $7, substr($8, 0, index($8, "?")-1)); } else { printf("%s %s\n", $7, $8); } } else if(NF==9) { # 例: Http Status Code: 408 # Methodの記録がないため最後列から2つめのデータを表示 print $(NF-2) } else { # 上記以外は列数を確認し出力列を選定する print NF print $0 } }
$ awk -f awk/uniq_urls.awk /var/somelocation/kshell-access_log* | more "GET / "GET /Books?sortOrder=title_desc&pageIndex=117 "GET / "GET /Books/Delete?id=57
#printf("%s %s\n", $7, $8); printf("%s %s\n", $7, substr($8, 0, index($8, "?")-1)); 上記へ処理を変更後 $ awk -f awk/uniq_urls.awk /var/somelocation/kshell-access_log* | more "GET / "GET /Books "GET / "GET /Books/Delete "GET / "GET /
$ awk -f awk/uniq_urls.awk /var/somelocation/kshell-access_log* | sort | uniq | -c | sort -nr | more 11838 "GET / 2803 "GET /Books 625 "GET /lib/bootstrap/dist/css/bootstrap.min.css 603 "GET /lib/bootstrap/dist/js/bootstrap.bundle.min.js 600 "GET /lib/jquery/dist/jquery.min.js