Using GNU bash 4.1.2, I get:
[roxma@VM_6_207_centos ~]$ echo `echo '\\'`
\
[roxma@VM_6_207_centos ~]$ echo $(echo '\\')
\\
The difference is documented in man bash
:
When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by $, `, or \. The first backquote not preceded by a backslash terminates the command substitution. When using the $(command) form, all characters between the parentheses make up the command; none are treated specially.
As per man bash
, a similar difference between the two forms is found if $
follows the backslash:
$ echo `echo 'out: \$'`
out: $
$ echo $(echo 'out: \$')
out: \$
And the same if a backtick follows the backslash:
$ echo `echo 'out: \`'`
out: `
$ echo $(echo 'out: \`')
out: \`
Since it could be useful to put a backtick as a character inside the command substitution, the backtick form has to have a way to escape a backtick. To make sure that one can put the escape character whereever one wants, then there also needs to be a way to escape the escape.