0

I want to replace the string from OLD to NEW and String contains special chars (, ", ', /, <, >)

OLD_STRING value:

<property name="jdbc.url" value="jdbc:oracle:thin:@//DBHOST:PORT/SID"/>

NEW_STRING value:

<property name="jdbc.url" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=DBHOST)(PORT=PORT))(CONNECT_DATA=(SERVICE_NAME=SID))(SECURITY=(SSL_SERVER_CERT_DN='C=US,ST=SOMESTATE,L=SOMECITY,O=COMPANY.com,OU=RRR,CN=CNAME')))"/>

I tried

sed -i -e "s|OLD_STRING|NEW_STRING|g" filename

But no luck as OLD/NEW_STRING contains special chars single/double quotes and backslash symbols

please suggest me SED command to accomplish the above request.

Arasu
  • 1
  • 1
  • OLD_STRING value: NEW_STRING value: – Arasu Feb 12 '21 at 15:03
  • 1
    Does this answer your question? [Escape a string for a sed replace pattern](https://stackoverflow.com/questions/407523/escape-a-string-for-a-sed-replace-pattern) – KamilCuk Feb 12 '21 at 15:23
  • No, i listed old and new patterns here. – Arasu Feb 12 '21 at 16:06
  • So run old and new pattern via the commands listed in the accepted answer in that thread I linked to. The accepted answer explains both parts and shows the commands that escape the patterns, in both parts of `s` command. – KamilCuk Feb 12 '21 at 17:42

0 Answers0