Using sed to delete a case insensitive matched line

eruina picture eruina · Jan 28, 2010 · Viewed 25.4k times · Source

How do I match a case insensitive regex and delete it at the same time

I read that to get case insensitive matches, use the flag "i"

sed -e "/pattern/replace/i" filepath

and to delete use d

sed -e "/pattern/d" filepath

I've also read that I could combine multiple flags like 2iw

I'd like to know if sed could combine both i and d I've tried the following but it didn't work

sed -e "/pattern/replace/id" filepath > newfilepath

Answer

Mark Byers picture Mark Byers · Jan 28, 2010

For case-insensitive use /I instead of /i.

sed -e "/pattern/Id" filepath