# 统计每个远程 IP 访问了本机 apache 几次?   
awk  '{ip[$1]++}END{for(i in ip){print ip[i],i}}'  /var/log/httpd/access_log  

# 统计 13:30 到 14:30 所有访问本机 Aapche 服务器的远程 IP 地址是什么   
# awk 使用‐F 选项指定文件内容的分隔符是/或者:  
# 条件判断$7:$8 大于等于 13:30,并且要求,$7:$8 小于等于 14:30  
awk -F "[ /:]" '$7":"$8>="13:30" && $7":"$8<="14:30"{print $1}' /var/log/httpd/access_log  

# 统计 13:30 到 14:30 所有访问 apache 服务器的请求有多少个  
awk -F "[ /:]" '$7":"$8>="13:30" && $7":"$8<="14:30"' /var/log/httpd/access_log |wc -l  

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code