如果你在linux下希望将程序或命令运行的信息,在输入到文件的同时,也能够显示在屏幕上,tee命令是个不错的选择。
help
tee --help
Usage: tee [OPTION]... [FILE]...
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
      --help     display this help and exit
      --version  output version information and exit
If a FILE is -, copy again to standard output.
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'tee invocation'
实例
ls -l | tee -a file.txt | less
说明:
- ls -l的输出重定向到- tee,- tee -a用于将内容存入- file.txt文件,- -a表示使用追加模式
- 管道符号将内容输出到less命令