tee
rose1 发表于 2020-07-19 05:32浏览次数:
在类似Unix的操作系统上,tee命令从标准输入读取,然后写入文件或标准输出。
本文档介绍了tee的GNU / Linux版本。
On Unix-like operating systems, the tee command reads from standard input, and writes to files or standard output.
This document covers the GNU/Linux version of tee.
目录:
1 tee 运行系统环境
2 tee 说明
3 tee 语法
4 tee 例子
tee 运行系统环境
tee 说明
所述三通命令在T-分离器在管道,其将水向两个方向和形状类似大写T之后命名
tee将数据从标准输入复制到每个FILE,也复制到标准输出。实际上,tee复制其输入,一次将其路由到多个输出。
The tee command is named after the T-splitter in plumbing, which splits water into two directions and is shaped like an uppercase T.
tee copies data from standard input to each FILE, and also to standard output. In effect, tee duplicates its input, routing it to multiple outputs at once.
tee 语法
tee [OPTION]... [FILE]...
选件
-a, --append
|
附加到给定的文件。不要覆盖。
|
-i, --ignore-interrupts
|
忽略中断信号。
|
--help
|
显示帮助消息,然后退出。
|
--version
|
显示版本信息,然后退出。
|
如果将FILE指定为破折号(“ - ”),则tee再次写入标准输出。
tee [OPTION]... [FILE]...
Options
-a, --append
|
Append to the given FILEs. Do not overwrite.
|
-i, --ignore-interrupts
|
Ignore interrupt signals.
|
--help
|
Display a help message, and exit.
|
--version
|
Display version information, and exit.
|
If a FILE is specified as a dash ("-"), tee writes again to standard output.
tee 例子
ls -1 *.txt | wc -l | tee count.txt
在上面的示例中,ls命令列出了当前目录中所有文件扩展名为.txt的所有文件,每行一个文件;此输出通过管道传递到wc,后者对行进行计数并输出数字;此输出通过管道传输到tee,后者将输出写入终端,并将相同的信息写入文件count.txt。如果count.txt已经存在,它将被覆盖。
ls -1 *.txt | wc -l | tee count.txt
In the above example, the ls command lists all files in the current directory that have the file name extension .txt, one file per line; this output is piped to wc, which counts the lines and outputs the number; this output is piped to tee, which writes the output to the terminal, and writes the same information to the file count.txt. If count.txt already exists, it is overwritten.