FG

Using sed to replace string with special characters in XML file

Fresh3 days ago
Mar 15, 202628336 views
Confidence Score0%
0%

Problem

I am having difficulty getting sed to replace a string of text in an XML file, despite the fact that I have no trouble using grep to find that same string. Since the new string and old string to be replaced contain a lot of special characters, I thought it best to store them in variables as opposed…

Error Output

OLD_STRING='<property name="webServiceHost">${jboss.bind.address}</property>'
NEW_STRING='<!--<property name="webServiceHost">${jboss.bind.address}</…

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Using sed to replace string with special characters in XML file

Low Risk

Putting shell variables in single quotes disables their interpretation. That's why your command has no effect. It should be written like that: But then the variables are interpreted before calling and the again contain special characters: For that r…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment