Awk - FilterByStatusCode
Examples - filter_bycode.awk
file:awk/filter_bycode.awk
#!/usr/bin/awk
BEGIN {
print "filter code:" filter_code
}
{
# もしHTTPレスポンスステータスコードの出力列が異なる場合
# 例
# if(NF==1) {
# if($7 == filter_code) {
# print somedata
# }
# }
if( $(NF-1) == filter_code) {
print $0
}
}
$ awk -f awk/filter_bycode.awk -v "filter_code=200" /var/somelocation/kshell-access_log* | more filter code:200 12.32.56.78 12.34.56.78:12345 - - [MM/MDAY/YYYY:HH:MM:SS +0900] "GET / HTTP/1.1" 200 3000 . .