分析Apache访问日志以获取最常用的IP地址

这使用awk从每个请求中获取IP地址,然后对前十名进行排序和汇总。
tail -10000 access_log | awk '{print $1}' | sort | uniq -c | sort -n | tail

命令用途:分析Apache访问日志以获取最常用的IP地址

花括号扩展

tail -10000 access_log | awk '{print $1}' | sort | uniq -c | sort -n | tail 利用 Bash 的花括号扩展(Brace Expansion)功能。

花括号中的内容会被展开为多个参数:

  • tail -10000 access_log | awk 'print $1' | sort | uniq -c | sort -n | tail

评论(0

暂无评论,来说两句吧

发表评论

回复 取消