How to specify a sed regexp address which is case-insensitive?
E.g.,
sed '/my-kw/d'
But I want sed to remove lines with my-kw in any cases.
Thanks
13 Answers
sed '/my-kw/Id'This will perform the match case-insensitive.
The switch is in uppercase itself, to avoid confusion with the i command that is offered by sed to insert a line into the stream.
Just use the I switch:
$ echo fooFOO | sed 's/o/a/Id'
faaFaaFrom the sed FAQ:
4GNU sed 3.02 and ssed also offer the /I switch for doing a case-insensitive match. For example,
echo ONE TWO | sed "s/one/unos/I" # prints "unos TWO"
This might work for you:
sed '/[mM][yY]-[kK][wW]/d' file or:
sed 'h;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;/MY-KW/d;x' file