Regex lookahead for ‘not followed by’ in grep

Negative lookahead, which is what you’re after, requires a more powerful tool than the standard grep. You need a PCRE-enabled grep.

If you have GNU grep, the current version supports options -P or --perl-regexp and you can then use the regex you wanted.

If you don’t have (a sufficiently recent version of) GNU grep, then consider getting ack.

Leave a Comment