What is the difference between backticks and $() in bash script? [duplicate]

StackOverflow https://stackoverflow.com/questions/8941381

  •  18-04-2021
  •  | 
  •  

Вопрос

I see in bash scripts two different forms which seems 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?

Это было полезно?

Решение

There is no 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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top