Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

grep - 使用grep进行负匹配(匹配不包含foo的行)(Negative matching using grep (match lines that do not contain foo))

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 .

(我需要查看已修改的所有文件,但名为error_log文件除外。)

I've read about it here , but only found one not -regex pattern.

(我在这里读过它 ,但只找到一个not -regex模式。)

  ask by jerrygarciuh translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

grep -v is your friend:

(grep -v是你的朋友:)

grep --help | grep invert  

-v, --invert-match select non-matching lines

(-v, - inverse-match选择不匹配的行)

Also check out the related -L (the complement of -l ).

(另请查看相关的-L-l的补码)。)

-L, --files-without-match only print FILE names containing no match

(-L, - files-without-match仅打印不包含匹配项的FILE名称)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...