Unix:混淆 Tee 命令的使用 [英] Unix: confusing use of the Tee -command
问题描述
手册指出三通是管件"工具.这些案例
使用 sudo
并将问题中的示例附加到文件中
ls -l |须藤 tee -a file.txt
Manual states that the tee is a "pipe fitting"-tool. The cases [1] confuse me:
1. case
echo "foo bar" | sudo tee -a /path/to/some/file
2. case
:w !sudo tee %
It is hard to understand the logic of tee from the cases. How does the tee work?
tee
is normally used to split the output of a program so that it can be both displayed and saved in a file. The command can be used to capture intermediate output before the data is altered by another command or program. The tee command reads standard input, then writes its content to standard output. It simultaneously copies the result into the specified file(s) or variables
tee [OPTION]... [FILE]...
For instance
tee [ -a ] [ -i ]... [ File ]...
-a
Appends the output to the end of File instead of writing over it.-i
Ignores interrupts.
With sudo
and appending to the file with your example in the question
ls -l | sudo tee -a file.txt
这篇关于Unix:混淆 Tee 命令的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!