I'm trying to replace a text string in an XML file with another using the sed tool command , but I can't get the result I expect.
Command:
sed -i -e -r 's|test-plugin.+\s\s*?<version>(.+)<\/version>|test-plugin.+\s\s*?<version>1.0.0<\/version>|g' plugins.xml
XML:
<plugins>
<plugin>
<name>test-plugin</name>
<version>3.0.0-SNAPSHOT</version>
</plugin>
<plugin>
<name>test-plugin-2</name>
<version>3.0.0-SNAPSHOT</version>
</plugin>
<plugin>
<name>test-plugin-3</name>
<version>2.0.0-SNAPSHOT</version>
</plugin>
</plugins>
The result I expect is that it replaces the version of the first plugin since it is the one that matches the name given in the command itself. Obviously, replace it respecting the line breaks and spaces of the XML structure.
Thank you very much in advance.