The backticks/gravemarks have been deprecated in favor of $()
for command substitution because $()
can easily nest within itself as in $(echo foo$(echo bar))
. There are other differences such as how backslashes are parsed in the backtick/gravemark version, etc.
See BashFAQ/082 for several reasons to always prefer the $(...) syntax.
Also see the POSIX spec for detailed information on the various differences.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…