sed 查找并替换为花括号

问题描述:

我正在尝试使用此命令:

I am trying to use this command:

sed -i 's#\{test1\}#test2#' /example/myfile.txt

test2 替换 {test1} 的实例.

To replace instances of {test1} with test2.

我收到错误:

sed: -e expression #1, char 17: Invalid preceding regular expression

我是不是没有正确地转义花括号?

Am I not escaping the curly braces correctly?

sed -i 's#{test1}#test2#' /example/myfile.txt

您不需要转义 {}