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}
}



tee MultiWriter creates a writer that duplicates its writes to all the // provided writers, similar to the Unix tee(1) command.的更多相关文章

  1. Linux shell tee指令学习

    转载自:http://blog.163.com/xujian900308@126/blog/static/12690761520129911304568/   tee tee:读取标准输入的数据,并将 ...

  2. tee 解决readonly 文件无法修改

    tee 是什么: 老规矩,找男人问.

  3. 可信执行环境(TEE)介绍

    可信执行环境(TEE)是Global Platform(GP)提出的概念.针对移动设备的开放环境,安全问题也越来越受到关注,不仅仅是终端用户,还包括服务提供者,移动运营商,以及芯片厂商.TEE是与设备 ...

  4. 可信执行环境TEE(转)

    硬件威胁:ARM的架构设计 软件威胁 TEE是中等安全级别 可信执行环境(TEE)是Global Platform(GP)提出的概念.针对移动设备的开放环境,安全问题也越来越受到关注,不仅仅是终端用户 ...

  5. Linux tee的花式用法和pee

    1.tee多重定向 tee [options] FILE1 FILE2 FILE3... tee的作用是将一份标准输入多重定向,一份重定向到标准输出/dev/stdout,然后还将标准输入重定向到每个 ...

  6. Linux tee命令详解

    Linux tee命令 Linux tee命令用于读取标准输入的数据,并将其内容输出成文件.如果文件指定为"-",则将输入内容复制到标准输出 tee指令会从标准输入设备读取数据,将 ...

  7. 可信执行环境(TEE)介绍 与应用

    原文:http://blog.csdn.net/wed110/article/details/53894927 可信执行环境(TEE,Trusted Execution Environment) 是G ...

  8. TEE&TrustZone

    一.TEE(Trusted Execution Environment) 1 A look back 1)2009 OMTP(Open Mobile Terminal Platform),首次定义了T ...

  9. 显示程序输出并复制到文件(tee 命令)

    Linux tee命令用于读取标准输入的数据,并将其内容输出成文件. tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件. 语法 tee [-ai][--help][--v ...

随机推荐

  1. Python常用内置对象

    1.在python中处理的一切都是对象. 2.内置对象可直接使用,如数字.字符串.列表.del等. 3.非内置对象需要导入模块才能使用,如正弦函数sin(x),随机数产生函数random()等.

  2. 如何重新加载 Spring Boot 上的更改,而无需重新启动服务器?

    这可以使用 DEV 工具来实现.通过这种依赖关系,您可以节省任何更改,嵌入式 tomcat将重新启动.Spring Boot 有一个开发工具(DevTools)模块,它有助于提高开发人员的生产力.Ja ...

  3. lua脚本简介

    Lua [1]  是一个小巧的脚本语言.它是巴西里约热内卢天主教大学(Pontifical Catholic University of Rio de Janeiro)里的一个由Roberto Ier ...

  4. GC算法与回收策略

    算法: 标记-清理  :首先标记出需要回收的对象 ,然后统一回收待标记的对象. 缺点:易产生大量空间碎片,空间碎片太多导致程序在运行过程中产生大对象时 因为空间不足导致容易导致另一个垃圾收集动作 标记 ...

  5. Java8的Optional:如何干掉空指针?

    目录 Optional概述 Optional简单案例 Optional的主要方法 参考阅读 Optional概述 Optional 是个容器:它可以保存类型T的value,或者仅仅保存null.Opt ...

  6. DBF 文件 ORACLE 数据库恢复

    DBF 文件 ORACLE 数据库恢复 清·魏源<庸易通义>:"至道问学之有知无行,分温故为存心,知新为致知,而敦厚为存心,崇礼为致知,此皆百密一疏." 起因 在我们的 ...

  7. spark的运行指标监控

    sparkUi的4040界面已经有了运行监控指标,为什么我们还要自定义存入redis? 1.结合自己的业务,可以将监控页面集成到自己的数据平台内,方便问题查找,邮件告警 2.可以在sparkUi的基础 ...

  8. C#处理医学图像(一):基于Hessian矩阵的血管肺纹理骨骼增强对比

    在医院实际环境中,经常遇到有问题的患者,对于一些特殊的场景,比如骨折,肺结节,心脑血管问题 需要图像对比增强来更为清晰的显示病灶助于医生确诊,先看效果: 肺纹理增强: 肺结节增强: 血管对比增强: 骨 ...

  9. [Leetcode刷题]——链表

    一.找出两个链表的交点 160.相交链表(easy)2021-01-05 编写一个程序,找到两个单链表相交的起始节点     如下面的两个链表,在c1 处相交: public class Soluti ...

  10. js 鼠标点击页面出现文字

    <script type="text/javascript"> var a_idx = 0; jQuery(document).ready(function($) { ...