shell programming - deprecated syntax

created onJanuary 18, 2022

use $(…) instead of backtics

Expressions like are still prevalent in the wild. If you work with shell script code that uses this deprecated code, you can do both your colleagues and yourself a favour by replacing that with for the following reasons:

  • Nesting is easier. Go figure out how to escape backticks in a nested expression. This is highly error prone.
  • It’s visually more clear that we are dealing with at an expansion.
  • Handling of backslashes is consistent, as shown in here:
$ echo '\$x' \$x $ echo `echo '\$x'` $x $ echo $(echo '\$x') \$x