在linux系统下,往往需要将软件打印同时输出到屏幕上和文件中,或者同时输出到屏幕和多个文件中,那么可使用以下方法:
同时输出到屏幕和文件: ./myapp | tee file.log
同时输出到屏幕和多个文件: ./myapp | tee file1.log file2.log
同时输出到屏幕和多个文件并追加到文件中: ./myapp | tee -a file1.log file2.log .... fileX.log
初学者应该注意:在使用脚本自动运行时,应该指明文件的路径
在linux系统下,往往需要将软件打印同时输出到屏幕上和文件中,或者同时输出到屏幕和多个文件中,那么可使用以下方法:
同时输出到屏幕和文件: ./myapp | tee file.log
同时输出到屏幕和多个文件: ./myapp | tee file1.log file2.log
同时输出到屏幕和多个文件并追加到文件中: ./myapp | tee -a file1.log file2.log .... fileX.log
初学者应该注意:在使用脚本自动运行时,应该指明文件的路径