0

Consider the following two scripts:

a=`ls -l`
a=$(ls -l)

This is a common use case for me, and I basically use both options interchangeably. Is there any difference? In which use case would you use one or another?

1 Answers1

2

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

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223