Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How to specify a sed regexp address which is case-insensitive?


sed '/my-kw/d'

But I want sed to remove lines with my-kw in any cases.


share|improve this question

3 Answers 3

up vote 2 down vote accepted
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.

share|improve this answer
Perfect thanks. Hmm, hope my following multi-line comment can go through $ jot -c 5 'A' | tee /dev/tty | sed '/c/Id' A B C D E A B D E –  xpt Jun 30 '13 at 13:28
No, my prevous multi-line comment didn't go through with nice formatting, but you can see that C was removed from the list. You can run the sample your self jot -c 5 'A' | tee /dev/tty | sed '/c/Id', where the jot is from the athena-jot package under Debian/Ubuntu. –  xpt Jun 30 '13 at 13:31

Just use the I switch:

$ echo fooFOO | sed 's/o/a/Id'

From the sed FAQ:

GNU 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"
share|improve this answer
and the ones who upvote the answer, my question is for sed address. See my comment on other thread. –  xpt Jun 30 '13 at 13:25

This might work for you:

sed '/[mM][yY]-[kK][wW]/d' file or:

sed 'h;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;/MY-KW/d;x' file

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.