如何使用SED替换文件中的“撇号" [英] How to replace to apostrophe ' inside a file using SED
本文介绍了如何使用SED替换文件中的“撇号"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文件"test.txt",其中包含以下内容
I have a file "test.txt" that contain the following
+foo+
+bar+
我要做的是将它们替换为:
What I want to do is to replace them into:
'foo'
'bar'
但是为什么此代码不起作用?
But why this code doesn't work?
sed 's/\+/\'/' test.txt
什么是正确的方法?
推荐答案
请改用"
.并添加g
标志以替换所有内容.
Use "
instead. And add g
flag to replace all.
sed "s/\+/\'/g" test.txt
这篇关于如何使用SED替换文件中的“撇号"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文