linux - Bash 脚本 : Diference between "$(command)" and `command`

标签 linux bash scripting sh

Possible Duplicate:
Command substitution: backticks or dollar sign / paren enclosed?

我想知道使用之间的区别

var="$(command)"

var=`command`

在 bash 脚本中,显然有两种方法可以获得相同的结果,但可能存在一些差异。

最佳答案

第一个更好,因为您可以嵌套命令替换并且不会变得尴尬。

Further Reading .

关于linux - Bash 脚本 : Diference between "$(command)" and `command` ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14151314/

相关文章:

linux - 当函数返回但函数中的命令在后台运行时会导致什么行为?

mysql - 如何从 bash shell 运行 Mysql 查询?

bash - 如何从脚本结束后仍然存在的 bash 脚本生成 bash 子 shell

c - 如何用windows主机文件响应请求?

shell - 批处理文件 - 命令行参数的数量

linux - 在 bash 脚本中一次运行多个循环

linux - 当监视器连接到 D-sub 连接器时,linux 会发出事件吗?

linux - 为 pid=<some number> 的进程找到有效的 id euid

linux - 在 bash 中比较整数和 float

javascript - 隐藏行后如何取消隐藏它?