所有重定向输出到文件 [英] Redirect all output to file
本文介绍了所有重定向输出到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道在Linux中,从屏幕输出重定向到一个文件,我既可以使用>
或 T恤
。不过,我不知道为什么输出的一部分仍然是输出到屏幕,而不是写入文件。
I know that in Linux, to redirect output from the screen to a file, I can either use the >
or tee
. However, I'm not sure why part of the output is still output to the screen and not written to the file.
有没有一种方法来重定向所有输出到文件?
Is there a way to redirect all output to file?
推荐答案
这部分内容的写入错误,都使用 2 - ;
重定向它。例如:
That part is written to stderr, use 2>
to redirect it. For example:
foo > stdout.txt 2> stderr.txt
如果你想在同一个文件:
or if you want in same file:
foo > allout.txt 2>&1
注:本工程(BA)SH,检查你的shell正确的语法
Note: this works in (ba)sh, check your shell for proper syntax
这篇关于所有重定向输出到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文