Sed regex change of file

前端 未结 1 825
走了就别回头了
走了就别回头了 2021-01-22 17:47

I am (unsuccessfully) trying to substitute the database host entry in a Magento local.xml file (the connection string file).

The line is the following:

&         


        
相关标签:
1条回答
  • 2021-01-22 18:14

    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>
    
    0 讨论(0)
提交回复
热议问题