sed is printing a substituted line twice

和自甴很熟 提交于 2020-01-21 09:08:30

问题


I am running the following command:

find /home/debajdas/checkout -name 'pom.xml' -or -name '*.properties' | xargs sed -i 's/10.0.0.0.3/10.0.0.0.4/gpw changes'

But it's replacing

<version>10.0.0.0.3</version>

with

<version>10.0.0.0.4</version>
<version>10.0.0.0.4</version>

Why is it getting replaced with 2 lines ?


回答1:


You must remove 'p' that prints current pattern space.

sed -i 's/10\.0\.0\.0\.3/10.0.0.0.4/gw changes'



回答2:


GNU sed

sed -i 's/\.3/.4/w changes'


来源:https://stackoverflow.com/questions/17145690/sed-is-printing-a-substituted-line-twice

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!