59.233.33.24 - - [09/Oct/2010:04:04:03 +0800] GET /pages/international/tejia.php HTTP/1.1 "200" 15708 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Sicent; WoShiHoney.B; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)" "-" 0.037
#按照空格分隔,最后一个字段[0.037] 是页面执行时间,第7个字段 是页面访问地址。
awk 'BEGIN{
print "Enter log file:";
getline logs;
#logs="/var/log/
nginx/access.log-20101008";
OFMT="%.3f";
while(getline < logs)
{
split($7,atmp,"?");
aListNum[atmp[1]]+=1;
aListTime[atmp[1]]+=$NF;
ilen++;
}
close(logs);
print "rntotal:",ilen,"rn========rn";
for(k in aListNum)
{
print k,aListNum[k],aListTime[k]/aListNum[k] | "sort -r -n -k3";
}
}'