What is the benefit of using $() instead of backticks in shell scripts? [duplicate]

There are two ways to capture the output of command line in bash:

  1. Legacy Bourne shell backticks ``:

    var=`command`
    
  2. $() syntax (which as far as I know is Bash specific, or at least not supported by non-POSIX old shells like original Bourne)

    var=$(command)
    

Is there any benefit to using the second syntax compared to backticks? Or are the two fully 100% equivalent?

9 Answers
9

Leave a Comment