一、man tee ,tee - read from standard input and write to standard output and files
命令读入标准数据然后标准输出同时把数据写入文件
TEE(1) User Commands TEE(1)
NAME
tee - read from standard input and write to standard output and files
SYNOPSIS
tee [OPTION]... [FILE]...
DESCRIPTION
Copy standard input to each FILE, and also to standard output.
-a, --append
append to the given FILEs, do not overwrite
-i, --ignore-interrupts
ignore interrupt signals
-p diagnose errors writing to non pipes
--output-error[=MODE]
set behavior on write error. See MODE below
--help display this help and exit
--version
output version information and exit
MODE determines behavior with write errors on the outputs:
'warn' diagnose errors writing to any output
'warn-nopipe'
diagnose errors writing to any output not a pipe
'exit' exit on error writing to any output
'exit-nopipe'
exit on error writing to any output not a pipe
The default MODE for the -p option is 'warn-nopipe'. The default operation when --output-error is not specified, is to exit immediately on error
writing to a pipe, and diagnose errors writing to non pipe outputs.
AUTHOR
Written by Mike Parker, Richard M. Stallman, and David MacKenzie.
二、我这里脚本上用到的地方。
三、下面的截图展示了这个输出内容不仅被写入 output.txt
文件,也被显示在标准输出中。
四、默认情况下,在同一个文件下再次使用 tee
命令会覆盖之前的信息。如果你想追加信息到文件的话,可以通过 -a
命令选项改变默认设置。
[command] | tee -a [file]
五、参考文章