I found this:
echo `echo \\n`
output is n
while
echo $(echo \\n)
output is \n
I knew $() can perform nesting while `` can't, but there seems to be other differences.
I found this:
echo `echo \\n`
output is n
while
echo $(echo \\n)
output is \n
I knew $() can perform nesting while `` can't, but there seems to be other differences.
The backquote is used in the old-style command substitution, e.g.
foo=`command`
The
foo=$(command)
syntax is recommended instead. Backslash handling inside $()
is less surprising, and $()
is easier to nest. See http://mywiki.wooledge.org/BashFAQ/082
`...`
syntax
In:echo `echo \\n`
`echo \\n`
return \n
textecho \n
returns n
echo -e "\n"
who returns a ASCII LF character$(...)
syntax
In:echo $(echo \\n)
`echo \\n`
return \n
text but with $(...)
returned like ONE token "\n"
echo "\n"
returns \n