【发布时间】:2019-05-11 06:52:16
【问题描述】:
我知道以前有人问过这个问题,但我似乎无法为我的 sed 命令获得正确的语法。
我需要将OPP/com.user.opp.orchest.po.services.stub-npo/npo-stub 替换为OPP/com.user.opp.orchest.po.services.stub-ica/npo-ica
我要替换的文件的 sn-p 如下:
config.xml
<compareType>PLAIN</compareType>
<pattern>
OPP/com.user.opp.orchest.po.services.stub-npo/npo-stub
</pattern>
<branches>
<com.sonyuser.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
<compareType>ANT</compareType>
<pattern>master</pattern>
</com.sonyuser.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
</branches>
${REPO_MIRROR}/OPP/com.user.opp.orchest.po.services.stub-npo/npo-stub
我已经尝试了以下,
sed -i '/^\/OPP/\com.user.opp.orchest.po.services.stub-npo/\npo-stub\/OPP/\com.user.opp.orchest.po.services.stub-ica/\npo-ica/g' config.xml
【问题讨论】:
-
您想仅在该行以该字符串开头或文件中的任何位置替换该字符串吗?
-
文件中的任何位置
标签: regex bash sed replace pattern-matching