使用 grep 进行负匹配(匹配不包含 foo 的行) [英] Negative matching using grep (match lines that do not contain foo)
本文介绍了使用 grep 进行负匹配(匹配不包含 foo 的行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试找出这个命令的语法:
grep !错误日志|找到/home/foo/public_html/-mmin -60
或:
grep '[^error_log]' |找到/home/baumerf/public_html/-mmin -60
我需要查看除名为 error_log
的文件之外的所有已修改文件.
我在这里读过,但只找到一个没有
-regex 模式.
解决方案
grep -v
是你的朋友:
grep --help |grep 反转
<块引用>
-v, --invert-match 选择不匹配的行
另外查看相关的-L
(-l
的补码).
-L, --files-without-match 只打印不包含匹配项的文件名
I have been trying to work out the syntax for this command:
grep ! error_log | find /home/foo/public_html/ -mmin -60
OR:
grep '[^error_log]' | find /home/baumerf/public_html/ -mmin -60
I need to see all files that have been modified except for those named error_log
.
I've read about it here, but only found one not
-regex pattern.
解决方案
grep -v
is your friend:
grep --help | grep invert
-v, --invert-match select non-matching lines
Also check out the related -L
(the complement of -l
).
-L, --files-without-match only print FILE names containing no match
这篇关于使用 grep 进行负匹配(匹配不包含 foo 的行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文