那是一种恶作剧。我希望您已经将apache日志类型设置为“Combined”,并且可以使用bashshell。然后命令
grep $IP $LOGFILE | awk '{ print $4$5, $7, "("$11")" }'
[07/Mar/2010:14:11:45+0100] /Doku/strawberrylimes.html ("-")
[07/Mar/2010:14:11:45+0100] /doku.css ("http://da.andaka.org/Doku/strawberrylimes.html")
[07/Mar/2010:14:11:45+0100] /images/zutaten.jpg ("http://da.andaka.org/Doku/strawberrylimes.html")
[07/Mar/2010:14:11:56+0100] /images/prost.jpg ("http://da.andaka.org/Doku/strawberrylimes.html")
[07/Mar/2010:14:11:56+0100] /images/vollermixer.jpg ("http://da.andaka.org/Doku/strawberrylimes.html")
[07/Mar/2010:14:11:57+0100] /favicon.ico ("-")
$IP
和
$LOGFILE
用你的价值观。。。结果来自我的Web服务器,只访问一页。)
如果您只对.html文件的请求感兴趣,请使用另一个grep扩展命令行:
grep $IP $LOGFILE | awk '{ print $4$5, $7, "("$11")" }' | grep -E '.+ .+\.html.* .+'
最后一个grep会过滤掉所有这样做的行
不
在输出的第二列中有一个“.html”字符串。但它也会过滤掉目录上的所有请求!