sed找到正则表达式和替换不起作用

时间:2017-11-06 22:44:08

标签: regex sed replace

我创建了以下正则表达式,它按照我的意愿工作(参见printscreen)。现在我的目标是在Linux上的sed内使用该正则表达式,并用符号"

替换每个突出显示的部分(请参阅printscreen)

enter image description here

所以在我做的终端中:

sed 's/("{2,})/@/g' new.csv > output.csv

它确实生成了与input.csv相同的文件output.csv!我没有收到错误消息。有人能告诉我出了什么问题吗?

输入文件[new.csv]

"""lkadjsklsdjlkdasjklsafd""""
""alksdfkldsaf""
"lasdfkkldasj"
"""salfdjkdsafjfkdlj"""""
lkasjdfkldjaf lkasj fkladsf "aslkdjalksdfkfdls;"
lkasdjlkdfj lkasjd kldj flk ""alksdfkklj;"" alsdkfjlkdas
" "laksdjkldsfj" "   should delete nothing 
""laksdjkldsfj""     should delete 

预期输出文件[output.csv]

"lkadjsklsdjlkdasjklsafd"
"alksdfkldsaf"
"lasdfkkldasj"
"salfdjkdsafjfkdlj"
lkasjdfkldjaf lkasj fkladsf "aslkdjalksdfkfdls;"
lkasdjlkdfj lkasjd kldj flk alksdfkklj;" alsdkfjlkdas
" "laksdjkldsfj" "   should delete nothing 
"laksdjkldsfj"     should delete 

0 个答案:

没有答案