使用sed删除不区分大小写的匹配行 [英] Using sed to delete a case insensitive matched line
本文介绍了使用sed删除不区分大小写的匹配行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何匹配不区分大小写的正则表达式并同时将其删除
How do I match a case insensitive regex and delete it at the same time
我读到要不区分大小写的匹配项,请使用标记 i
I read that to get case insensitive matches, use the flag "i"
sed -e "/pattern/replace/i" filepath
并删除使用d
sed -e "/pattern/d" filepath
我还读到我可以组合多个标记,例如2iw
I've also read that I could combine multiple flags like 2iw
我想知道sed是否可以同时组合i和d
我尝试了以下方法,但没有用
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
推荐答案
不区分大小写的用途 / I
而不是 / i
。
For case-insensitive use /I
instead of /i
.
sed -e "/pattern/Id" filepath
这篇关于使用sed删除不区分大小写的匹配行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文