Updating the license tag in XML file with new license

Hi All,

I have a XML file : System.xml in which I want to update the license tag with the new data from file licence.xml.
The content of files is in following format:

System.xml:

<?xml version="1.0"?>
<!DOCTYPE Configuration SYSTEM "SystemVariables.dtd">
<usageConfiguration docformat="750">
<SystemEnvironmentVariables>
<CEM>
<Node>
.............
</Node>
<SNMP>
<SNMP.Community>public</SNMP.Community>
<SNMP.Port>12799</SNMP.Port>
</SNMP>
<Log>
<Log.Size>100000</Log.Size>
<Log.Verbosity>DEBUG</Log.Verbosity>
</Log>
</CEM>
<UIS>
<Node>
<Node.Host>ablsdf</Node.Host>
<Node.Port>12800</Node.Port>
<Node.MonitoringEnabled>false</Node.MonitoringEnabled>
<Node.UpdateInterval>30000</Node.UpdateInterval>
<Node.ErrorLogSize>10</Node.ErrorLogSize>
<Node.PeakInterval>30000</Node.PeakInterval>
</Node>
<SNMP>
<SNMP.Community>public</SNMP.Community>
<SNMP.Port>12801</SNMP.Port>
</SNMP>
<Log>
<Log.Size>10000</Log.Size>
<Log.Verbosity>DEBUG</Log.Verbosity>
</Log>
</UIS>
<Licenses>
<License id="21">
<![CDATA[SYSTEM Evaluation
1,Entire System,none,1,03 Mar 2011
Host: FB528400
Issued: 2010-03-03 09-52-08
Key: 302c0214-6f52b3e7-62331491-211792a2-57a74684-319976
a4839989-a9021461-8a2e645a-9bb254cc-d8a6a7-5f3785eb]]>
</License>
</Licenses>
</SystemEnvironmentVariables>
</XACCTusageConfiguration>

licence.xml:

<License id="21">
<![CDATA[SYSTEM Evaluation
1,Entire System,none,1,25 Feb 2012
Host: FB528400
Issued: 2011-02-25 08-22-13
Key: 302c0214-2a86887c-d6362791-141a7a9f-115a7349-3c6f9c
af021467-f9d40ebd-bbcf6391-93614c60-fccee95d-c7ad31]]>
</License>

I want to write a shell script for this.

awk -v t=0 't==1{getline < "license.xml"}/<Licenses>/{t=1}1' system.xml
1 Like

Thanks rdcwayx :slight_smile:

This command updates the required license but tags following the license are still missing i.e. :
</Licenses>
</SystemEnvironmentVariables>
</XACCTusageConfiguration>

So please help on this