I'm writing a bash script, and I need it to make changes to an XML file, replacing a bunch of different servlet-name items with "disabledController".
I know I can do this using sed, however there are 2 different lines that have the same string, but only one needs to be changed.
For example, I need to change this:
<servlet>
<servlet-name>CreateCertificateAuthorityBackup</servlet-name>
<servlet-class>com.company.ca.CABackup</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CreateCertificateAuthorityBackup</servlet-name>
<url-pattern>createCertificateAuthorityBackup</url-pattern>
</servlet-mapping>
Into this:
<servlet>
<servlet-name>CreateCertificateAuthorityBackup</servlet-name>
<servlet-class>com.company.ca.CABackup</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>disabledControler</servlet-name>
<url-pattern>createCertificateAuthorityBackup</url-pattern>
</servlet-mapping>
If I use sed like so:
sed "s@<servlet-name>CreateCertificateAuthorityBackup.*@<servlet-name>disabledController</servlet-name>@"
It replaces both servlet-name items instead of just the 2nd one. Is there a way to do what I want to do here?