According to documentation, single quotes in bash preserve all literal characters, however the following:
echo 'a\nb'
Outputs:
a
b
(i.e. the literal \ and n have been replaced with a newline)
Why is this the case? (what am I missing?)
Also, what other characters does this affect?
For reference I’m using GNU bash, version 3.2.57(1)-release (arm64-apple-darwin22)
>Solution :
bash doesn’t. echo does. But if you had written it as $'a\nb', bash would have done the interpretation.