gpt4 book ai didi

linux - 运行 bash 脚本时,echo 输出到哪里?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:44:41 24 4
gpt4 key购买 nike

如果脚本在终端中运行,以下内容将输出到标准输出:

 echo "some message"

如果脚本被另一个脚本调用,输出到哪里?是否涉及任何重大开销?

我使用的是 GNU bash,版本 4.3.33。

非常感谢

最佳答案

输出

echo "some message"

应该转到 stdout 除非(不排他)

  1. 您有一个 o/p 重定向,如下所示,它会影响 echo 语句。

    exec 1>/dev/null # 1 is the file descriptor for stdout, this should be before the echo

    ./script >outfile # The whole output is redirected to a file
  2. 在 echo 命令之前有一个do-nothing 指令(:)

    : echo "some message" # Does nothing

关于linux - 运行 bash 脚本时,echo 输出到哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38523888/

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