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 -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -