linuxtee命令使用详解(大量实例)

上传人:桔**** 文档编号:513095060 上传时间:2022-08-26 格式:DOC 页数:6 大小:21KB
返回 下载 相关 举报
linuxtee命令使用详解(大量实例)_第1页
第1页 / 共6页
linuxtee命令使用详解(大量实例)_第2页
第2页 / 共6页
linuxtee命令使用详解(大量实例)_第3页
第3页 / 共6页
linuxtee命令使用详解(大量实例)_第4页
第4页 / 共6页
linuxtee命令使用详解(大量实例)_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《linuxtee命令使用详解(大量实例)》由会员分享,可在线阅读,更多相关《linuxtee命令使用详解(大量实例)(6页珍藏版)》请在金锄头文库上搜索。

1、文档供参考,可复制、编制,期待您的好评与关注! tee功能说明:读取标准输入的数据,并将其内容输出成文件。语 法:tee -ai-help-version文件补充说明:tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件。我们可利用tee把管道导入的数据存成文件,甚至一次保存数份文件。参 数:-a 附加到既有文件的后面,而非覆盖它。如果给予tee指令的文件名称已经存在,预设会覆盖该文件的内容。加上此参数后,数据会新增在该文件内容的最后面,而不会删除原先之内容。-i 忽略中断信号-help 在线帮助-version 显示版本信息范 例:列出文本文件slayers.sto

2、ry的内容,同时复制3份副本,文件名称分别为ss-copy1、ss-copy2、ss-copy3:$ cat slayers.story |tee ss-copy1 ss-copy2 ss-copy3tee -ai-help-version文件.【功能】tee以标准输入作为输入,标准输出和文件作为输出。【举例】tee file /覆盖tee -a file /追加tee - /输出到标准输出两次tee - - /输出到标准输出三次tee file1 file2 - /输出到标准输出两次,并写到那两个文件中ls | tee file 另:把标准错误也被tee读取ls * 2&1 | tee ls

3、.txt *用tee生成一个文件,包含你敲入的内容:复制代码代码如下:$tee testfile这样,会提示要你用标准输入输入内容,然后敲回车会将你输入的内容写入testfile和输出到标准输出,如果用Ctrld结束输入(Ctrlc也行)。如果原来testfile有内容,将会覆盖。*把内容追加到文件的末尾行:复制代码代码如下:$tee -a testfile结果类似上,不过如果原来testfile有内容则不会覆盖而是追加。*生成一个文件,敲入的时候,不接受中断信号:复制代码代码如下:$tee -i testfile结果同testfile,不过不会接收中断信号,只能用Ctrld结束,而不能用Ct

4、rlc了。*执行ls列出目录文件同时将输出保存到文件test中:复制代码代码如下:$ls | tee test这样,会像平时一样执行ls命令并将当前目录的文件名输出到标准输出。另外由于进行了tee命令,所以会生成一个test文件,这个test文件的内容和标准输出的内容一样。【描述】tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件。可以用于既想看到标准输出,又想将标准输出保存到文件中的情况。参数:-a或-append 附加到既有文件的后面,而非覆盖它-i-i或-ignore-interrupts 忽略中断信号。-help 在线帮助。-version 显示版本信息。

5、常用参数格式:tee只输出到标准输出,因为没有指定文件嘛。格式:tee file输出到标准输出的同时,保存到文件file中。如果文件不存在,则创建;如果已经存在,则覆盖之。(If a file being written to does not already exist, it is created. If a file being written to already exists, the data it previouslycontained is overwritten unless the -a option is used.)格式:tee -a file输出到标准输出的同时,追加

6、到文件file中。如果文件不存在,则创建;如果已经存在,就在末尾追加内容,而不是覆盖。格式:tee -输出到标准输出两次。(A FILE of - causes tee to send another copy of input to standard output, but this is typically not that useful as the copies are interleaved.) 格式:tee file1 file2 -输出到标准输出两次,同时保存到file1和file2中。 使用示例补充:示例一 tee命令与重定向的对比rootweb # seq 5 1.txt r

7、ootweb # cat 1.txt 12345rootweb # cat 1.txt 2.txt rootweb # cat 1.txt | tee 3.txt 12345rootweb # cat 2.txt 12345rootweb # cat 3.txt 12345rootweb # cat 1.txt 2.txt rootweb # cat 1.txt | tee -a 3.txt 12345rootweb # cat 2.txt 1234512345rootweb # cat 3.txt 1234512345rootweb # 示例二 使用tee命令重复输出字符串rootweb #

8、 echo 12345 | tee 12345rootweb # echo 12345 | tee - 1234512345rootweb # echo 12345 | tee - - 123451234512345rootweb # echo 12345 | tee - - - 12345123451234512345rootweb # echo 12345 | tee - - - - 1234512345123451234512345rootweb #rootweb # echo -n 12345 | tee 12345rootweb # echo -n 12345 | tee - 123

9、4512345rootweb # echo -n 12345 | tee - - 123451234512345rootweb # echo -n 12345 | tee - - - 12345123451234512345rootweb # echo -n 12345 | tee - - - - 1234512345123451234512345rootweb # 示例三 使用tee命令把标准错误输出也保存到文件rootweb # ls * ls: *: 没有那个文件或目录rootweb # ls * | tee - ls: *: 没有那个文件或目录rootweb # ls * | tee ls.txt ls: *: 没有那个文件或目录rootweb # cat ls.txt rootweb # ls * 2&1 | tee ls.txt ls: *: 没有那个文件或目录rootweb # cat ls.txt ls: *: 没有那个文件或目录rootweb # /

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 国内外标准规范

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号