Negative matching using grep (match lines that do not contain foo)

grep, regex

Solution

`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

Problem

How do I match all lines not matching a particular pattern using `grep`? I tried this: ``` grep '[^foo]' ```

Original source

Related problems