Linux 更好地引用shell脚本上执行的命令
我不确定这两者之间的区别,以及哪一个是在shell脚本中执行命令的更好引用 例如,我有两个例子:Linux 更好地引用shell脚本上执行的命令,linux,shell,Linux,Shell,我不确定这两者之间的区别,以及哪一个是在shell脚本中执行命令的更好引用 例如,我有两个例子: echo "The name of the computer is `uname -n`" echo "The name of the computer is $(uname -n)" 哪一个更好?还是没有区别?通常建议使用$(…)一个,因为它嵌套起来更容易。比较: date -d "1970-01-01 $(echo "$(date +%s)-3600"|bc) sec UTC" date -
echo "The name of the computer is `uname -n`"
echo "The name of the computer is $(uname -n)"
哪一个更好?还是没有区别?通常建议使用$(…)
一个,因为它嵌套起来更容易。比较:
date -d "1970-01-01 $(echo "$(date +%s)-3600"|bc) sec UTC"
date -d "1970-01-01 `echo \"\`date +%s\`-3600\"|bc` sec UTC "
通常推荐使用$(…)
一个,因为它更容易嵌套。比较:
date -d "1970-01-01 $(echo "$(date +%s)-3600"|bc) sec UTC"
date -d "1970-01-01 `echo \"\`date +%s\`-3600\"|bc` sec UTC "
+1快速浏览时很容易混淆反勾号和单引号。有关更多信息,请参见+1。快速浏览时,很容易混淆反勾号和单引号。有关更多信息,请参阅。