I’d like to replace all the \r\n with < br/ >in a document, and I’m trying this see script below
# sed -i 's/\r\n/<br/>' ~/xxd/*
however i got this error back
sed: -e expression #1, char 12: unknown option to `s’
How do i solve this problem?
Thanks!
Your problem is that you have the
/separator in your replacement string sosedis assuming that’s the end of your replacement, and that the>following it is a flag.If your
sedis modern enough, just use a different separator character, one that’s not in the replacement string:Alternatively, you can escape the offending character but I try to avoid that since it tends to lead to overly sawtooth
sedcommands like/\/\/\/\/\/\.The other thing you may want to watch out for is trying to use
\nin your regex sincesedoperates on lines anyway. If your intent is to just strip carriage returns and insert HTML line breaks, then the followingsedcommand may be better: