You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

修改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 tells sed to 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:43:52