As the sed implemented in FreeBSD does not support any escape sequence in the replace pattern, I have to use "\'$'\n" to represent a newline and "'$'\n". It does support backslash by "\" though.
Unfortunately, combining the newline with backslash cause error for me. For example, I want to add a line starts with a tab and "line added.\" after every line with "key:\", I wrote:
#!/bin/bash
sed -E 's/^key:\\$/&\'$'\n'$'\tline added.\\/g' file
It thrown me an error like:
sed: 2: "s/^key:\\$/&\
line add ...": unterminated substitute in regular expression
How do I combine both newline and backslash in the substitute argument of sed?
Thanks a ton!