I have the following XML data:
<info>
<data>
<name>my_image</name>
<value>site.com/image1.img</value>
</data>
<data>
<name>my_link</name>
<value>site.com/p_info</value>
</data>
</info>
I want to replace all the site.com to siteimag.com of every my_image value (just for the my_image attributes).
So the result will be:
<info>
<data>
<name>my_image</name>
<value>siteimag.com/image1.img</value>
</data>
<data>
<name>my_link</name>
<value>site.com/p_info</value>
</data>
</info>
How can it be done with sed command?
Thanks.
sed '/my_image/{n;s/site.com/siteimag.com/}' file
Brief explanation,
/my_image/
: search the line contained "my_image"n
.s/site.com/siteimag.com/
: do the substitutionIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With