I am using XMLStartlet for a quick deploy cmd (Windows) script for my app, and I am changing the configuration xml file.
Manipulation of the whole nodes/attributes works just perfect, but i need to replace a part of an attribute with a specific value, for example:
<list>
<address id="a1">
<data url="http://localhost:8000/a1.html" />
</address>
<address id="a2">
<data url="http://localhost:8000/a2.html" />
</address>
</list>
I need to change the port part of a /list/address/data/@url
to get:
<list>
<address id="a1">
<data url="http://localhost:8001/a1.html" />
</address>
<address id="a2">
<data url="http://localhost:8001/a2.html" />
</address>
</list>
Any help with a suitable xmlstarlet command would be much appreciated. I don't want to mix sed into my script.
Using XPath string functions,
concat
andsubstring-after
:You can edit
--inplace
instead ofmove
: