Ever wondered how to exclude a string from grep? Last week I decided to dig until I find the answer, as I had to find a “lost” DB2 script in a pile of archives. It turns out that grep has a feature called “grep for all except”. Finally found that on a mailing list archive of COLUG. Here is how it works:
grep pattern1 file | grep -v pattern2