我有一个文件,每行都有一个字符串......即。
test.434
test.4343
test.4343t34
test^tests.344
test^34534/test
我想找到任何包含“^”的行并将整行替换为空白。
我试图使用 sed:
sed -e '/\^/s/*//g' test.file
这似乎不起作用,有什么建议吗?
最佳答案
sed -e 's/^.*\^.*$//' test.file
例如:
$ cat test.file test.434 test.4343 test.4343t34 test^tests.344 test^34534/test $ sed -e 's/^.*\^.*$//' test.file test.434 test.4343 test.4343t34 $
要完全删除有问题的行,请使用
$ sed -e '/\^/d' test.file test.434 test.4343 test.4343t34
关于regex - 查找包含 "^"的行并将整行替换为 "",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3374429/