sed

sed find and replace with curly braces


I am trying to use this command:

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

To replace instances of {test1} with test2.

I get the error:

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

Am I not escaping the curly braces correctly?


Solution

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

    You don't need to escape {}