I have a file that contains information as so:
20 BaDDOg
31 baddog
42 badCAT
43 goodDoG
44 GOODcAT
and I want to delete all lines that contain the word dog
. This is my desired output:
42 badCAT
44 GOODcAT
However, the case of dog
is insensitive.
I thought I could use a sed command: sed -e "/dog/id" file.txt
, but I can't seem to get this to work. Does it have something to do with me working on an OSX? Is there any other method I could use?
Best Answer
Try
grep
:-i
to ignore case and-v
to invert the matches.If you want to use
sed
you can do:GNU
sed
extends pattern matching with theI
modifier, which should make the match case insensitive but this does not work in all flavors ofsed
. For me, this works:but it won't work on OS X.