Issue
How to (inside a bash script) replace a string like <toto>*<titi>
with <toto>fixed string<titi>
using sed, provided that *
is a wildcard?
Solution
I suspect that this would do it:
sed -E 's/<toto>[^<]*<titi>/<toto>fixed string<titi>/g'
...but I'd try to make sure that the opening tag <titi>
is always the first one following <toto>
. My sed line will not replace something
in
<toto>something<foo>another value<titi> ...
since it breaks at the first peek at <
(the [^<]*
- which means: any amount of anything but <
) and requires that it's followed by <titi>
Answered By - Ted Lyngmo Answer Checked By - Senaida (WPSolving Volunteer)