shell统计日志行数

统计日志行数:

1. wc -l nginx_access.log.2011-09-26

2. awk 'END{print NR}' nginx_access.log.2011-09-26

3. awk '{max=max>NR?max:NR}END{print max}' nginx_access.log.2011-09-26



查看每小时的请求访问次数,脚本如下:
for i in 2011-09-24 2011-09-25 2011-09-26; 
do 
    echo $i; 
    cat /opt/work/log/nginx_access.log.$i | awk '{print $1}' | awk -F ':' '{print $2}' | sort | uniq -c; 
done;
 

猜你喜欢

转载自genggeng.iteye.com/blog/1181097