我一直在试图找出这个命令的语法:
grep ! error_log | find /home/foo/public_html/ -mmin -60要么
grep '[^error_log]' | find /home/baumerf/public_html/ -mmin -60我需要查看已修改的所有文件,但名为error_log文件除外。
我在这里读过它 ,但只找到一个not -regex 模式。
grep -v是你的朋友:
grep --help | grep invert-v, - inverse-match 选择不匹配的行
另请查看相关的-L ( -l的补码)。
-L, - files-without-match 仅打印不包含匹配项的 FILE 名称
您还可以将awk用于这些目的,因为它允许您以更清晰的方式执行更复杂的检查:
不包含foo :
awk '!/foo/'既不包含foo也不包含bar :
awk '!/foo/ && !/bar/'既不包含foo也不包含bar行包含foo2或bar2 :
awk '!/foo/ && !/bar/ && (/foo2/ || /bar2/)'等等。
在你的情况下,你可能不想使用 grep,而是在 find 命令中添加一个否定子句,例如
find /home/baumerf/public_html/ -mmin -60 -not -name error_log如果要在名称中包含通配符,则必须将它们转义,例如,排除带有后缀. log 的文件:
find /home/baumerf/public_html/ -mmin -60 -not -name \*.log