Although [
doesn't have any special meaning in a double-quoted bash string, \[
still evaluates to [
since backslashes are processed to allow for escaping dollar signs. Try
sed "s|\\[#${key}#\\]|${value}|g"
as your sed
command. The double backslash will causes a literal backslash to be sent to sed
, which will use it to escape the [
to treat it literally as well.