The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-08-2008
chiru_h chiru_h is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 72
replace string in XML with sed

Greetings,
I have an XML : file.xml

Code:
<component>
       <name>abcd</name>
       <value>1234</value>
</component>

I am using sed to replace abcd with the desired value dynamically without knowing the actual value.

Code:
sed 's/<name>[-[:alnum:]./]\{1,\}<\/name>/<name>ijkl<\/name>/' file.xml > newfile.xml

I don't have any issues with this command in Linux but on Solaris machine, I am getting the error:
Quote:
sed: command garbled: /<name>[-[:alnum:]./]\{1,\}<\/name>/<name>ijkl<\/name>/
If I remove >[-[:alnum:]./]\{1,\} and put the actual value, it is fine. But I have do it dynamically as I use it within the script to replace the existing value with the given value.

Can somebody please advise.

Thanks,
Chiru

Last edited by Yogesh Sawant; 04-08-2008 at 02:45 PM.. Reason: added code tags