Reputation: 11
I have an XML file having tags <![CDATA[]]>
& I need to replace this tag with
<![CDATA[XXX]]>
when am trying to replace using
sed command :sed 's/<![CDATA[]]>/<![CDATA[XXX]]>/g' stores.xml
i can't see any changes on my file.
Please help me in finding the solution.
Upvotes: 0
Views: 108
Reputation: 59426
Try this:
sed -i 's/<!\[CDATA\[\]\]>/<!\[CDATA\[XXX\]\]>/g' stores.xml
You need to escape the brackets, otherwise they mean in regexp syntax "any of the enclosed characters".
To see the changes applied to an existing file, use the option -i
. Alternatively you can use
sed ... < stores.xml > new_stores.xml
Which, for testing at least, might be more of your taste because it creates a new file with the result and leaves the original untouched. (Use mv new_stores.xml stores.xml
afterwards in case the result looks fine.)
Upvotes: 2