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

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

  •  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