The error appears because your variables (at least some of them) contain colons (:
) and you use a colon as the delimiter for the s/…/…/
command. Actually for the s:…:…:
command in your case.
When you have
var="ex:ample"
and then try to issue
sed -e "s:${var}:sample:g" some_file
then the shell interpolates the variable before handing it over to sed
, and sed
is called like so:
sed -e "s:ex:ample:sample:g" some_file
and the s:…:…:
is now broken. It looks like you are telling sed
to replace ex
with ample
and apply the options s
, a
, m
, p
, l
, and e
.
To avoid this, use a different delimiter which you are sure of it doesn't appear in your text. Popular delimiters are +
and #
but you can choose any character. The delimiter is in fact the first character after the s
, so
sed -e "s#…#…#" some_file
sed -e "s+…+…+" some_file
sed -e "s'…'…'" some_file
will all do.