我正在使用以下命令来删除包含的行hotmail
sed -i '/^[^\t]*\t[^\t]*hotmail/d' ./file
测试数据为
"foxva****omes****","[email protected]","8*** Rd","Ne***ah","Wi***in","54***","*******"
"foxva****omes****","[email protected]","8*** Rd","Ne***ah","Wi***in","54***","*******"
"foxva****omes****","[email protected]","8*** Rd","Ne***ah","Wi***in","54***","*******"
目前这仅删除第一行。第二行和第三行不会被删除,因为它们包含大写字母。我怎样才能改变它不区分大小写。
答案1
尝试这个:
sed -i '/^[^\t]*\t[^\t]*hotmail/dI' ./file
但是,如果您不使用现代 GNU sed,您可能会陷入困境:
sed -i '/^[^\t]*\t[^\t]*[hH][oO][tT][mM][aA][iI][lL]/d' ./file
此链接指向 GNU sed 手册解释I
和其他修饰符。
答案2
sed 有一个 I 标志,您可以添加它以进行不区分大小写的匹配。
看https://stackoverflow.com/questions/2157288/using-sed-to-delete-a-case-insensitive-matched-line