Welcome to the Linux Foundation Forum!

find and replace variables for multiple xml tags.

Hello All,

    i have some tagged variables in xml which i want to modify from source and target using sed or awk.

source:

  <cdb_name oa_var="s_cdb_name">EBS2SIT</cdb_name>
  <cdb_unique_name oa_var="s_cdb_unique_name"/>
  <global_db_name oa_var="s_dbSid">PEBS2SIT</global_db_name>
  <db_name_lower oa_var="s_dbSidLower">pebs2sit</db_name_lower>

    should be like below in target: ( copied the same source file to target and modified)

  <cdb_name oa_var="s_cdb_name">EBSPAT2</cdb_name>
  <global_db_name oa_var="s_dbSid">PEBSPAT</global_db_name>
  <db_name_lower oa_var="s_dbSidLower">pebspat</db_name_lower>

    LIKE WISE HAVE MANY WITH IN TAG

    I CAPTURED USING AWK the above values in variable

SOURCE:
S_PDBNAME_C= PEBS2SIT,
S_PDBNAME_S= pebs2sit,
S_UNIQ=EBS2SIT_12345,
S_CDBINST= EBS2SIT2,
S_INSTNAME= EBS2SIT

TARGET:
T_PDBNAME_C= PEBSPAT,
T_PDBNAME_S= pebspat,
T_UNIQ= EBSPAT_12345,
T_CDBINST= EBSPAT2,
T_INSTNAME= EBSPAT2

    used below to modify the source and target.

sed -i 's/$S_PDBNAME_S/$T_PDBNAME_S/g' $S_FILE

    challenge is although command is successful but the value in target file is just the same
    i need to directly modify the tagged variable with out creating temp variable or create 
    temp variable and modify the file with source and target variable.

sed -i 's/$S_PDBNAME_S/$T_PDBNAME_S/g' $S_FILE

outputs :
<global_db_name oa_var="s_dbSid">PEBS2SIT</global_db_name>

please share some solution I'm really exhausted with all combinations avail on google.

thanks in advance.
any input from your end is really valuable for me...

regards
Rahman Syed

Answers

Categories

Upcoming Training