gpt4 book ai didi

linux - 更好地引用在 shell 脚本上执行命令

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:21:38 25 4
gpt4 key购买 nike

我怀疑其中的区别,以及哪一个是在 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 -d "1970-01-01 `echo \"\`date +%s\`-3600\"|bc` sec UTC "

关于linux - 更好地引用在 shell 脚本上执行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4981419/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com