I want to add one line in xml file. My xml file contains as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<ftp_destination_ip>0.0.0.0</ftp_destination_ip>
<ftp_destination_user>root</ftp_destination_user>
<ftp_destination_pass>undefined</ftp_destination_pass>
<other_unix_backup_path>/root/BACKUP</other_unix_backup_path>
<other_backup_folder>BACKUP</other_backup_folder>
<source_confirmation_needed>false</source_confirmation_needed>
<keep_ems_running_after_restore>false</keep_ems_running_after_restore>
<remote_connection_timeout>120000</remote_connection_timeout >
<history>
<manage_backup_history>true</manage_backup_history>
<backup_history_num_of_days>7</backup_history_num_of_days>
</history>
</configuration>
And I want to add two lines that will be 3th and 4th line in the XML:
<remote_connection_protocol>sftp</remote_connection_protocol>
<ftp_destination_ip>0.0.0.0</ftp_destination_ip>
The output should be like that:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--remote connection protocol>false|ftp|sftp</remote connection protocol-->
<remote_connection_protocol>sftp</remote_connection_protocol>
<ftp_destination_ip>0.0.0.0</ftp_destination_ip>
<ftp_destination_user>root</ftp_destination_user>
<ftp_destination_pass>undefined</ftp_destination_pass>
<other_unix_backup_path>/root/BACKUP</other_unix_backup_path>
<other_backup_folder>BACKUP</other_backup_folder>
<source_confirmation_needed>false</source_confirmation_needed>
<keep_ems_running_after_restore>false</keep_ems_running_after_restore>
<remote_connection_timeout>120000</remote_connection_timeout >
<history>
<manage_backup_history>true</manage_backup_history>
<backup_history_num_of_days>7</backup_history_num_of_days>
</history>
</configuration>
Thanks
sed
,awk
and friends could do the job, you might whish to usexmlstartlet
to do such thing, see p16 Include one XML document into another using XInclude xmlstar.sourceforge.net/doc/xmlstarlet.pdf