What is the difference between backticks and $() in a Bash script?

9.2k views Asked by At

I see two different forms in Bash scripts which seem to do the same:

`some command`

and

$(some command)

What is the difference between the two, and when should I use each one of them?

1

There are 1 answers

5
thiton On BEST ANSWER

There isn't any semantic difference. The backtick syntax is the older and less powerful version. See man bash, section "Command Substitution".

If your shell supports the $() syntax, prefer it because it can be nested.