4

I wonder if there is a significant difference of calling sub shell via $(...) or `...`?

For example:

a=$(ls -la /tmp | grep vox-*)

And:

a=`ls -la /tmp | grep vox-*`

The result will be the completely the same, but I want to know why there are two different methods, what the difference is, and which one I should use.

Will
  • 1,157

1 Answers1

3

Backsticks and $(...) are identical in terms of functionality. However I prefer the second approach

  • $(...) can be easily nested

  • readability, $(...) is more "bashish"

  • consistency, as a similar syntax, $((...)), is for expressions

See also this page that has other arguments.

Déjà vu
  • 5,778