gpt4 book ai didi

linux - shell 脚本 - 将所有数据从 stdout 重定向到/dev/null

转载 作者:太空宇宙 更新时间:2023-11-04 12:53:08 24 4
gpt4 key购买 nike

<分区>

我使用 travis-ci 从头开始​​构建 linux 7.8 版。在构建期间,travis-ci 抛出错误,因为日志文件大于 4 兆字节。你可以在lfs-auto, build #15看到

现在,我想将所有数据从 stdout 重定向到/dev/null 以减少日志文件的大小。通常,人们将每个命令的重定向操作用作 dev/null。但是这样会使 shell 脚本变得太长且难以阅读

有没有人有解决这些问题的想法?


问题解决了!感谢大家有意见

我选择解决方案 exec >/dev/null 因为该命令将 all 输出从 std 重定向到/dev/null 而无需其他操作。在这种情况下,exec >/dev/nullscript-file >/dev/null{ command, ... } 简单,易于编辑>/dev/null


解决问题重复

加上一些评论,这个问题的内容与How do I redirect the output of an entire shell script within the script itself?相同和 how to redirect output of multiple commands to one file

我知道我的问题与 How do I redirect the output of an entire shell script within the script itself? 相同,但我的问题更清楚,更短

我需要更多评论来解决两种情况下的重复问题

  • 将此问题与其他问题合并并删除此问题
  • 删除这个问题什么都不做
  • 什么都不做

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