Your problem is that you have the /
separator in your replacement string so sed
is assuming that's the end of your replacement, and that the >
following it is a flag.
If your sed
is modern enough, just use a different separator character, one that's not in the replacement string:
pax$ echo hello | sed -e 's/e/<br />/'
sed: -e expression #1, char 9: unknown option to `s'
pax$ echo hello | sed -e 's?e?<br />?'
h<br />llo
Alternatively, you can escape the offending character but I try to avoid that since it tends to lead to overly sawtooth sed
commands like /\/\/\/\/\/\
.
The other thing you may want to watch out for is trying to use \n
in your regex since sed
operates on lines anyway. If your intent is to just strip carriage returns and insert HTML line breaks, then the following sed
command may be better:
s?\r$?<br />?