Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Bash 脚本中看到了两种不同的形式,它们似乎做同样的事情:
`some command`
和
$(some command)
两者之间有什么区别,我应该什么时候使用它们中的每一个?
没有任何语义差异。反引号语法是较旧且功能较弱的版本。请参阅man bash,“命令替换”部分。
如果您的 shell 支持该$()语法,请更喜欢它,因为它可以嵌套。
$()