nginx_log.sh
#!/bin/bash
code=(100 101 200 201 202 203 204 205 206 300 301 302 303 304 305 306 307 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 500 501 502 503 504 505)
for log in `find . -type f -name "*.log"`;do for i in ${code[*]};do awk -v a=$i '$9 == a {print}' $log > $log.$i.txt;done;done
ua=(Macintosh Windows compatible iPad iPod iPhone Android Linux Ubuntu Debian Kali x86 X11 Symbian Java Wayland Unknown)
for u in ${ua[*]};do for a in `find . -type f -name "*.txt"`;do grep $u $a > $a.$u.txt;if [ ! -s $a.$u.txt ];then rm -f $a.$u.txt;fi;done;done
spider=(Googlebot Baiduspider TwitterBot Bytespider bingbot Linespider AhrefsBot PetalBot BLEXBot DataForSeoBot DotBot DuckDuckGo MagiBot MojeekBot SemrushBot SurdotlyBot KomodiaBot Sogou YisouSpider 360Spider msnbot yandex)
for s in ${spider[*]};do for p in `find . -type f -name "*.txt"`;do grep $s $p > $p.$s.txt;if [ ! -s $p.$s.txt ] ;then rm -f $p.$s.txt;fi;done;done
for txt in `find . -type f -name "*.txt"`;do if [ ! -s $txt ];then rm -f $txt;fi;done
最后更新于