Grep Regex: List all lines except

awk, grep, regex, sed

Solution

That should do it:

grep -v 'T[^H]'

-v : print lines not matching

[^H]: matches any character but H

Problem

I'm trying to automagically remove all lines from a text file that contains a letter "T" that is not immediately followed by a "H". I've been using grep and sending the output to another file, but I can't come up with the magic regex that will help me do this. I don't mind using awk, sed, or some other linux tool if grep isn't the right tool to be using.

Original source