https://zh.wikipedia.org/wiki/Tee

在计算机科学中,tee是一个常见的指令,它能够将某个指令的标准输出,导向、存入某个档案中。许多不同的命令行界面Shell)都提供这个功能,如 Unix shellWindows PowerShell

tee的功能通常是用管道,让它不但能在萤幕输出,而且也能够将它储存在档案中。当一个资料在被另一个指令或程式改变之前的中间输出,也能够用tee来捕捉它。tee命令能够读取标准输入,之后将它的内容写入到标准输出,同时将它的副本写入特定的档案或变数中。

tee [ -a ] [ -i ] [檔案 ... ]

参数:

  • 檔案 一个或多个档案,能够接收 tee-d 的输出。

Flags:

  • -a 追加(append)到目标文件而不是覆盖
  • -i 忽略中断。

[cpy@public ~]$ ll -as
总用量 32
0 drwx------ 10 cpy cpy 206 12月 25 17:50 .
0 drwxr-xr-x. 8 root root 111 12月 25 15:45 ..
12 -rw------- 1 cpy cpy 12194 12月 23 19:58 .bash_history
4 -rw-r--r-- 1 cpy cpy 18 8月 3 2016 .bash_logout
4 -rw-r--r-- 1 cpy cpy 193 8月 3 2016 .bash_profile
4 -rw-r--r-- 1 cpy cpy 231 8月 3 2016 .bashrc
0 drwxrwxr-x 4 cpy cpy 34 12月 9 19:12 .cache
0 drwxrwxr-x 3 cpy cpy 18 11月 25 11:53 .config
4 -rw-rw-r-- 1 cpy cpy 35 12月 25 17:50 file
0 drwxrwxr-x 7 cpy cpy 120 12月 23 16:59 game_manager
0 drwxrwxr-x 4 cpy cpy 28 12月 9 19:12 go
4 drwxrwxr-x 10 cpy cpy 4096 11月 26 12:25 perfCCpp
0 drwxrw---- 3 cpy cpy 19 12月 9 19:12 .pki
0 drwxrwxr-x 5 cpy cpy 176 12月 14 11:53 soft
0 drwx------ 2 cpy cpy 25 11月 25 12:21 .ssh
[cpy@public ~]$ ll -as | tee file | cat
总用量 28
0 drwx------ 10 cpy cpy 206 12月 25 17:50 .
0 drwxr-xr-x. 8 root root 111 12月 25 15:45 ..
12 -rw------- 1 cpy cpy 12194 12月 23 19:58 .bash_history
4 -rw-r--r-- 1 cpy cpy 18 8月 3 2016 .bash_logout
4 -rw-r--r-- 1 cpy cpy 193 8月 3 2016 .bash_profile
4 -rw-r--r-- 1 cpy cpy 231 8月 3 2016 .bashrc
0 drwxrwxr-x 4 cpy cpy 34 12月 9 19:12 .cache
0 drwxrwxr-x 3 cpy cpy 18 11月 25 11:53 .config
0 -rw-rw-r-- 1 cpy cpy 0 12月 25 17:51 file
0 drwxrwxr-x 7 cpy cpy 120 12月 23 16:59 game_manager
0 drwxrwxr-x 4 cpy cpy 28 12月 9 19:12 go
4 drwxrwxr-x 10 cpy cpy 4096 11月 26 12:25 perfCCpp
0 drwxrw---- 3 cpy cpy 19 12月 9 19:12 .pki
0 drwxrwxr-x 5 cpy cpy 176 12月 14 11:53 soft
0 drwx------ 2 cpy cpy 25 11月 25 12:21 .ssh
[cpy@public ~]$

  

In computing, tee is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input.[1] It is primarily used in conjunction with pipes and filters. The command is named after the T-splitter used in plumbing.[2]

 

 

Example usage of tee: The output of ls -l is redirected to tee which copies them to the file file.txt and to the pager less. The name tee comes from this scheme - it looks like the capital letter T

The tee command 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. The syntax differs depending on the command's implementation.

io/multi.go


// MultiWriter creates a writer that duplicates its writes to all the
// provided writers, similar to the Unix tee(1) command.
//
// Each write is written to each listed writer, one at a time.
// If a listed writer returns an error, that overall write operation
// stops and returns the error; it does not continue down the list.
func MultiWriter(writers ...Writer) Writer {
allWriters := make([]Writer, 0, len(writers))
for _, w := range writers {
if mw, ok := w.(*multiWriter); ok {
allWriters = append(allWriters, mw.writers...)
} else {
allWriters = append(allWriters, w)
}
}
return &multiWriter{allWriters}
}



最新文章

  1. Nginx 使用 sever 段规则屏蔽恶意 User Agent
  2. 设计模式六大原则(5)—迪米特法则
  3. struts返回json
  4. ORACLE10G工作原理
  5. ECSHOP给分类添加图
  6. C#中dynamic的正确用法 以及 typeof(DynamicSample).GetMethod("Add");
  7. highcharts 根据表格转化为不同的图表
  8. c语言通过时间种子产生随机数并选出最大值以及下标
  9. 转载:Struts2+Jquery实现ajax并返回json类型数据
  10. php __FILE__,__CLASS__等魔术变量,及实例
  11. POJ 3276 Face The Right Way 翻转(开关问题)
  12. 深入探讨List<>中的一个姿势。
  13. Docker简介/安装/使用
  14. 安卓自定义View实现钟表
  15. css3自适应布局单位vw,vh你知道多少?
  16. apt-get本地软件源搭建
  17. bootloader介绍
  18. 浅谈 js中parseInt函数的解析
  19. 测试那些事儿—简述CPU的工作原理
  20. 好文推荐:转载一篇别人kaggle的经验分享

热门文章

  1. 轻松上手CSS Grid网格布局
  2. 处理xls文件
  3. 转【深入理解SQL的四种连接-左外连接、右外连接、内连接、全连接】
  4. Idea利用maven创建web项目,并配置tomcat
  5. MySql Docker 主主配置
  6. 一行 CSS 代码的魅力
  7. vue element 表单验证不通过,滚动到固对应位置
  8. Sentry(v20.12.1) K8S 云原生架构探索,玩转前/后端监控与事件日志大数据分析,高性能+高可用+可扩展+可伸缩集群部署
  9. netty之EventLoop源码分析
  10. Java的nanoTime()方法