shell解析nginx日志

1
2
3
4
5
6
7
8
9
10
grep '2019:14' nginx-access.log* | grep -v 'DNSPod' | awk '{print $1, $4, $9, $(NF-4), $NF, $(NF-2) }' > ~/trade20190210.log
grep '2019:09' nginx-access.log* | grep -v 'DNSPod' | awk '{ if($NF > 1) print $1, $4, $9, $(NF-4), $NF, $(NF-2) }' > ~/trade20190210.log
grep '2019:09' nginx-access.log* | grep -v 'DNSPod' | awk '{ if($NF > 1) print $0 }' > ~/trade20190211.log
grep '2019:14' nginx-access.log* | grep -v 'DNSPod' | awk '{ if($NF-$(NF-2)>0.1) print $1, $4, $9, $(NF-4), $NF, $(NF-2) }' > ~/trade20190210.log
grep '2019:14' nginx-access.log* | grep -v 'DNSPod' | awk '{ if($NF-$(NF-2)>0.1) print $0 }' > ~/trade20190210.log
grep '2019:14' nginx-access.log* | grep -v 'DNSPod' | awk '{if($NF>5) print $0 }' > ~/trade20190210-14.log

cat nginx-access.log- | grep -v 'DNSPod' | awk '{if($NF>0&&$NF<1) print $0 }' > ~/trade20190210.log
grep '2019:09' nginx-access.log* | grep -v 'DNSPod' | awk '{ if($9>=400&&$9<500) print $9 }' > ~/trade20190211.log
awk '{arr[$1]+=1}END{for(i in arr)print i,arr[i]}' ~/trade20190211.log