| 递归 | grep -rn 关键字 /etc |
|---|---|
| 过滤文件 | --include='*.conf' |
| 上下文 | -A3 后 3 行、-B3 前 3 行 |
典型用法
典型用法
grep -rn 'Listen' /etc/nginx --include='*.conf'
grep -iE 'error|fail' /var/log/messages | tail
grep -v '^#' /etc/ssh/sshd_config | grep -v '^$'
journalctl -b | grep -i oom | head大目录全文搜索可换 ripgrep(rg),默认忽略 .git 且速度更快。