Sed regex change of file -


i (unsuccessfully) trying substitute database host entry in magento local.xml file (the connection string file).

the line following:

<host><![cdata[localhost]]></host> 

i want find line contains "host" sed , replace content of inner brackets else.

note - content of inner brackets won't "localhost", s/localhost/lala/g won't work.

i got following:

sed -i "/\<host\>/s/.../lala/2" local.xml 

help please.

with gnu sed:

sed 's|\(<host><!\[cdata\[\).*\(\]\]></host>\)|\1lala\2|' file 

or

sed -e 's|(<host><!\[cdata\[).*(\]\]></host>)|\1lala\2|' file 

output:

<host><![cdata[lala]]></host> 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -