Assume that I have the following line:
group blue:green yellow green redtomblue black !greyTOMwhilte !purple redblue
I need to delete from it all words that contain the string "tom" or "TOM" using sed.
I have managed to get this far:
sed 's/^ *\(.*\)[!]*[A-Za-z0-9_]*[tT]\{1\}[oO]\{1\}[mM]\{1\}[A-Za-z0-9_]*\(.*\)/\1 \2/g'
But this only deletes the last occurrence, not all of them. Using my example above the result is:
group blue:green yellow green redtomblue black !grey !purple redblue
How can I use sed to remove any word containing either of the specific substrings "tom" or "TOM"?