There is one line in my bash script file like this:
echo "$string" | sed -e "s|\($str\)|$(wrap \\1 $1 $2)|"
Now, I want to wrap the $1
and $2
with double quotes for preventing errors while $1
equals to null
.
I tried to add \
before "
, like "\"$1\" \"$2\""
but it does not work.
How can I do that?
sed
script is terribly fragile. Could you explain what$string
and$str
are and what you want to achieve. Are you generating commands that you later execute?wrap
to be invoked for every line with the captured string as argument or do you expectwrap
to be given a literal\1
as argument and its output to be used to generate the content of thesed
inline script?