regex: match lines that don't match sub-regex
Let's say I have a regex expression foobar and I want to find all lines in a document that contain no match to foobar. Can I do this? 开发者_如何学运维How do I do this?
^(?!.*foobar.*).+$
With multiline option, matches all line that does not contain foobar..
The regexp for your case can be this
^((?!foobar))$
edited:
but if you only want grep something you can use -v parameter:
grep -v foobar
精彩评论