egrep might be the better choice for a program. Anyway, the second sed example could be done this way:
sed -n '/third/!p' inputfile >outputfile
The test is for lines that do not contain the word third, however, since you might want to exclude both 'third' and 'Third', this might work better:
sed '/third/d;/Third/d' inputfile >outputfile
There is a logical relationship that you might want to keep in mind, However, I'm not certain how to express it in a forum:
NOT ( A AND B ) = NOT A OR NOT B
Not A would be expressed on paper with a bar over the A.
|