Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix 同时输出到屏幕和文件以调试程序_Unix_Pipe - Fatal编程技术网

Unix 同时输出到屏幕和文件以调试程序

Unix 同时输出到屏幕和文件以调试程序,unix,pipe,Unix,Pipe,如果我有一个程序,比如:test.sh,有时需要通过观察屏幕输出进行调试,并在程序到达输出中的某个点时终止程序。对于特别详细的输出,将此输出放在文件中以及终端中可能很有用 在代码和调试工具中执行此操作的最佳方法是什么?输出可以通过以下行进行管道传输: ./test.sh | tee -a Log.log 这将打印到屏幕上,并将输出从test.sh写入Log.Log 应重新打开此问题以允许其他答案,例如直接编辑代码,例如写入文件和代码中的std::cout(对于c++)。

如果我有一个程序,比如:
test.sh
,有时需要通过观察屏幕输出进行调试,并在程序到达输出中的某个点时终止程序。对于特别详细的输出,将此输出放在文件中以及终端中可能很有用


在代码和调试工具中执行此操作的最佳方法是什么?

输出可以通过以下行进行管道传输:

./test.sh | tee -a Log.log

这将打印到屏幕上,并将输出从test.sh写入Log.Log

应重新打开此问题以允许其他答案,例如直接编辑代码,例如写入文件和代码中的
std::cout
(对于
c++
)。