I know I can do this with SED. But in my specific task it is kind of complex. So I couldn't figure it out despite the many examples across this site.
I have a configuration file with credentials.
<username><![CDATA[prefix_cms]]></username>
<password><![CDATA[complexpwd]]></password>
<dbname><![CDATA[prefix_cms]]></dbname>
I want to change all credentials to a new unique value. This is a problem when I use find an replace with SED because it changes the username AND the dbname to its new value.
The new values should be for instance:
newusername
newpassword
newdbname
How would I do this? I have looked for first occurence in SED but couldn't get it working for some reason.
I have also tried to find and replace the whole line including the XML and CDATA protions, but this makes it more complex because of the spcial characters.
How can I solve this?
EDIT:
The output I am looking for.
<username><![CDATA[newusername]]></username>
<password><![CDATA[newpassword]]></password>
<dbname><![CDATA[newdbname]]></dbname>
Looking for the first answer I see I have not been very clear about what I wanted.
EDIT2:
I found a perfect solution here: Sed regex change of file