脚本代码
date1=`date -d "$date1" +%Y%H%M` logpath="access.log" cat $logpath |awk -v now=$date1 'BEGIN{count=0}{if(match($4,'/\\\\/[0-9:]+/')){ date=substr($4,RSTART+1,10);if(date>=now && match($10,"500")){count=count+1;}}} END{print count}'
脚本代码
date1=`date -d "$date1" +%Y%H%M` logpath="access.log" cat $logpath |awk -v now=$date1 'BEGIN{count=0}{if(match($4,'/\\\\/[0-9:]+/')){ date=substr($4,RSTART+1,10);if(date>=now && match($10,"500")){count=count+1;}}} END{print count}'