test@debian:~$ echo `echo \`echo uh!\``uh!How does the Bash do that? It seems that it first executes the expression in the non-escaped backticks, which gives back (the double-quotes  are removed, right?):`echo uh!`So we have an input equivalent to:test@debian:~$ echo `echo uh!`(side note: really, why does it work? Because:test@debian:~$ echo `echo uh!`-bash: !`: event not found)Then Bash executes the expression in backticks again, which gives:test@debian:~$ echo uh!Which finally gives us the output:uh!Is that right? And how could one encapsulate four echo-backtick-expression into each other?
Backtick command encapsulation
bash;shell;command substitution
Depends on your version of bash:bash-4.2$ echo `echo \`echo uh!\``bash: !\``: event not foundbash-4.3$ echo `echo \`echo uh!\``uh!In bash-4.3, ! is no longer eligible as a history event designator, so history expansion does not apply.Other than that, it's just normal backtick nesting syntax. Inside backticks, the backslash character is overloaded (yet again) to do that nested expansion again.You can nest as many levels as you want:echo `echo \`echo \\\`echo \\\\\\\`echo whatever\\\\\\\`\\\`\``Which is the cumbersome equivalent of:echo $(echo $(echo $(echo $(echo whatever))))However note that in both versions, the command substitution is subject to word splitting. So, you'd want to quote them to prevent it.With bash, dash, pdksh, yash, zsh, it's relatively easy:echo `echo \`echo \\\`echo \\\\\\\`echo whatever\\\\\\\`\\\`\``With the Bourne or Korn shell, you also need to escape the  though, so that becomes:echo `echo \\`echo \\\\\\`echo \\\\\\\\\\\\\\`echo whatever\\\\\\\`\\\\\\\\\\`\\\\`\`Compare with:echo $(echo $(echo $(echo $(echo whatever)))) 