相关疑难解决方法(0)

Shell:将stdout重定向到/ dev/null,将stderr重定向到stdout

我在对cyberciti.biz的评论中看到了这个有趣的问题.

我发现我甚至找不到一种灵活的方法来用sh执行单行命令.

到目前为止,我对解决方案的想法是:

tmp_file=`mktemp`
(./script 2>$tmp_file >/dev/null; cat $tmp_file) | ./other-script
rm tmp_file
Run Code Online (Sandbox Code Playgroud)

但是你看,这不是同步的,而且很致命,它太难看了.

欢迎大家分享一下这个.:)

linux bash shell sh

47
推荐指数
2
解决办法
5万
查看次数

标签 统计

bash ×1

linux ×1

sh ×1

shell ×1