From
man sed, I read:
\cregexpc
Match lines matching the regular expression regexp. The c may be any character.
On the one hand
- sed '\cncd' <<< n correctly shows empty output, since it's the same as sed '/n/d' <<< n based on the description above;
- sed '\c\ccd' <<< c correctly shows an empty output too, but in this case the letter needed to be escaped for obvious reasons.
On the other hand:
- sed '\n\nnd' <<< n results in an output equal to the single character n, revealing that the backslash is having a double effect:
- it prevents the following n from closing the opening \n.
- it interprets the n as a newline instead of the literal letter n; this is confirmed by executing echo -e 'a\na' | sed -n 'N;\n\nnp'.
The is means that using
n in
\nregexpn prevevents the use of the literal
n in the
regexp.
Kind regards,
Enrico Maria De Angelis