我怎样才能重定向控制台输出到文件? [英] How can I redirect console output to file?
本文介绍了我怎样才能重定向控制台输出到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新的C。
有没有简单的方法来重定向所有的控制台输出(printfs输出等)使用一些通用的命令行\\联动参数文件(无需修改任何原始code的)?
I'm new to c. Is there any simple way to redirect all the console's output (printfs etc.) to a file using some general command line \ linkage parameter (without having to modify any of the original code)?
如果这样程序是什么?
推荐答案
使用的shell输出重定向
Use shell output redirection
您的命令> outputfile.txt
的标准误差仍将输出到控制台。如果你不希望出现这种情况,是:
The standard error will still be output to the console. If you don't want that, use:
您的命令> outputfile.txt 2 - ;&放大器; 1
或
您的命令和放大器;> outputfile.txt
您也应该看看 T恤
工具,它可以使重定向到两个地方一次。
You should also look into the tee
utility, which can make it redirect to two places at once.
这篇关于我怎样才能重定向控制台输出到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文