用单引号替换所有双引号

问题描述:

我正在尝试用单引号替换字符串中的所有双引号.这是我的表达:

I'm trying to replace all double quotes in a string with single quotes. here my expression:

echo "<a href=\"#\" id=\"resendActivationMailLink\">here</a>" | sed "s/\"/'/"

不幸的是只替换了第一个双引号 :S

unfortunately only the first double quote is replaced :S

<a href='#" id="resendActivationMailLink">here</a> 

有什么想法吗?

您需要将 g 标志传递给 sed:

You need to pass the g flag to sed:

sed "s/\"/'/g"