#!/bin/bash
# Define the log file
logfile="access.log"
# Use grep to find lines containing 'XXXX', then awk to count occurrences by IP
grep 'XXX' "$logfile" | awk '{print $1}' | sort | uniq -c | sort -nr
脚本过滤nginx日志是不是存在某个字符的IP及其访问次数
最新推荐文章于 2025-12-21 11:47:57 发布
该文章介绍了如何使用Bash命令行工具grep和awk,结合sort和uniq,从access.log文件中查找包含XXXX的行,然后按IP地址计数每个IP的出现次数。
1700

被折叠的 条评论
为什么被折叠?



