~$ echo $'\'test'
'test
man bash
says:
Enclosing characters in single quotes preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.
Why does it work in the echo
-command then?
Single quotes
'...'
are different to dollar single quotes$'...'
. The former doesn't support any backslashing, while the latter uses the ANSI C specification.choroba
's answer is totally correct, here the details fromman bash
:That's why!