修改sed命令实现批量替换XML转义引号为单引号
Fixing Global Replacement in Sed Command
Hey there! I see the issue—your sed command is only replacing the first instance of " because by default, sed stops after the first match per line. To get it to replace all occurrences in each line, you just need to add the g (global) flag to your substitution expression.
Modified Command
Here's the updated version of your full command:
grep -rl """ ./ | xargs sed -i "s/"/'/g"
What Changed?
The key addition is the g at the end of the sed substitution:
s/"/'/: This is the basic substitution pattern (find", replace with')g: The global flag tellssedto replace every match in the line, not just the first one.
Verification
If you run this modified command on your sample text:
"are "insulin sensitizers" "
You'll get the expected result:
"are 'insulin sensitizers' "
内容的提问来源于stack exchange,提问作者seanysull
相关产品推荐
相关产品推荐

