I wish to sed
some strings part of an XML .SLA scribus file, in a script.
Simplified script :
replaced="$1"
replacement="$2"
sed -i "s/$replaced/$replacement/gI" afile.sla
Issue is that $1 and $2 have to be escaped beforehand.
For example with $2 being an empty string, this works fine :
sed -i "s/<ITEXT FONT=\"LiberationSerif\" FCOLOR=\"Green\" CH=\"Youpeeee\"\/>//gI" afile.sla
This works fine and this is the goal to achieve, but the $1 and $2 are not escaped at first. I have found several questions and answers (as How can I escape a double quote inside double quotes?) on how the escaped strings should be, but none on how a script can do this escaping. Both the /
and the "
should be escaped.
So which script command will escape the $1 and $2 strings so as to use them as argument to sed
?