-1

Possible Duplicate:
Command substitution: backticks or dollar sign / paren enclosed?

I want know the difference between use

var="$(command)"

and

var=`command`

in bash scripting, aparently are two ways to get the same result, but is possible that exist some diferences.

Community
  • 1
  • 1

2 Answers2

1

The first is better, as you can nest the command substitutions and it doesn't become awkward.

Further Reading.

alex
  • 460,746
  • 196
  • 858
  • 974
1

From bash man page:

When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by ‘$’, ‘`’, or ‘\’. The first backquote not preceded by a backslash terminates the command substitution. When using the $(command) form, all characters between the parentheses make up the command; none are treated specially.

(more interesting things there; do read the whole thing :) )

Amadan
  • 179,482
  • 20
  • 216
  • 275