1

What's the difference between

failed_instance=`aws deploy`

and

failed_instance=$(aws deploy)

I'm talking about ` and $(?

Rue Vitale
  • 1,549
  • 4
  • 17
  • 24

1 Answers1

5

Both are semantically identical, and both are mandated by the POSIX sh standard, but $() is the newer, modern syntax.

  • Backslash handling is the same as usual inside $(), but backslashes require escaping (lots of escaping if nesting) inside backticks.
  • It nests cleanly. Compare

    printf '%s\n' "$(foo "$(bar)")"     # new POSIX sh syntax
    

    to its old-style equivalent...

    printf '%s\n' "`foo \"\`bar\`\"`"   # legacy Bourne syntax
    
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441