I do have a file like this:
<receiver name="anything" type="com.mycompany.plugin.Timer">
<property name="interval">5000</property>
<handler name="ReplaceThis" type="com.mycompany.handler.FileBuilderHandler">
<property name="buildSomething">true</property>
<handler name="AlsoReplaceThis" type="com.mycompany.handler.FileExporter">
<property name="overide">true</property>
</handler>
</handler>
</receiver>
<receiver name="anything/other" type="com.mycompany.plugin.Timer">
<property name="intervall">1000</property>
<handler name="ThisMustBeReplaceAsWell" type="com.mycompany.handler.FileWatcher">
<property name="interval">2000</property>
<handler name="ThisMustBeReplaceAsWell" type="com.mycompany.converter.CSConverter">
<property name="mandant">CE</property>
<handler name="RemoveThis" type="com.mycompany.handler.FileExporter">
<property name="outputDir">/usr1/import</property>
</handler>
</handler>
Now I want all lines with the following beginning
<handler name="
to be replace from
<handler name="ReplaceThis" type="com.mycompany.handler.FileBuilderHandler">
to someting like this
<handler name="FileBuilderHandler" type="com.mycompany.handler.FileBuilderHandler">
So the attribute "name" should have the Classname (last part of the type attribute)
Does anyone has an idea how to solve that with an sed, awk, grep command?
xmlstarlet
) to perform operations such as this. See stackoverflow.com/a/1732454/1421075