In BRE (basic regular expression) mode (i.e. without the -E
or -r
command line option) braces are not special, while escaped braces are used for quantifiers like \{1,3\}
. The error message is because standalone
can't be parsed as a numeric quantifier. So you want {standalone}
:
$ printf '%s\n' 'documentclass{standalone}' | sed 's/documentclass{standalone}/documentclass[class=memoir]{standalone}/gp'
documentclass[class=memoir]{standalone}
documentclass[class=memoir]{standalone}
Alternatively keep the escaped braces, but use ERE (extended regular expression) mode:
$ printf '%s\n' 'documentclass{standalone}' | sed -r 's/documentclass\{standalone\}/documentclass[class=memoir]{standalone}/gp'
documentclass[class=memoir]{standalone}
documentclass[class=memoir]{standalone}
Note that in either case, nothing in your RHS needs escaping.
See also:
Note also that at least in GNU sed, -is
will edit the file in-place, creating a backup file with suffix s
. If you want to pass the -i
and -s
options you must do so separately or in the other order -si
. However iirc -i
implies -s
so the latter is likely superfluous.