Ubuntu tee
问题描述:使用matlab输出大量日志记录,一定量是,不可再看之前的了,所以输出到文档:
用途说明
在执行Linux命令时,我们可以把输出重定向到文件中,比如 ls >a.txt,这时我们就不能看到输出了,如果我们既想把输出保存到文件中,又想在屏幕上看到输出内容,就可以使用tee命令了。tee命令读取标准输入,把这些内容同时输出到标准输出和(多个)文件中(read from standard input and write to standard output and files. Copy standard input to each FILE, and also to standard output. If a FILE is -, copy again to standard output.)。在info tee中说道:tee命令可以重定向标准输出到多个文件(`tee': Redirect output to multiple files. The `tee' command copies standard input to standard output and also to any files given as arguments. This is useful when you want not only to send some data down a pipe, but also to save a copy.)。要注意的是:在使用管道线时,前一个命令的标准错误输出不会被tee读取。
常用参数
格式: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 previously
contained is overwritten unless the `-a' option is used.)
格式:tee -a file
输出到标准输出的同时,追加到文件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命令与重定向的对比
[root@web ~]# seq 5 >1.txt
[root@web ~]# cat 1.txt
1
2
3
4
5
[root@web ~]# cat 1.txt >2.txt
[root@web ~]# cat 1.txt | tee 3.txt
1
2
3
4
5
[root@web ~]# cat 2.txt
1
2
3
4
5
[root@web ~]# cat 3.txt
1
2
3
4
5
[root@web ~]# cat 1.txt >>2.txt
[root@web ~]# cat 1.txt | tee -a 3.txt
1
2
3
4
5
[root@web ~]# cat 2.txt
1
2
3
4
5
1
2
3
4
5
[root@web ~]# cat 3.txt
1
2
3
4
5
1
2
3
4
5
[root@web ~]#
示例二使用tee命令重复输出字符串
[root@web ~]# echo 12345 | tee
12345
[root@web ~]# echo 12345 | tee -
12345
12345
[root@web ~]# echo 12345 | tee - -
12345
12345
12345
[root@web ~]# echo 12345 | tee - - -
12345
12345
12345
12345
[root@web ~]# echo 12345 | tee - - - -
12345
12345
12345
12345
12345
[root@web ~]#
[root@web ~]# echo -n 12345 | tee
12345[root@web ~]# echo -n 12345 | tee -
1234512345[root@web ~]# echo -n 12345 | tee - -
123451234512345[root@web ~]# echo -n 12345 | tee - - -
12345123451234512345[root@web ~]# echo -n 12345 | tee - - - -
1234512345123451234512345[root@web ~]#
示例三使用tee命令把标准错误输出也保存到文件
[root@web ~]# ls "*"
ls: *: 没有那个文件或目录
[root@web ~]# ls "*" | tee -
ls: *: 没有那个文件或目录
[root@web ~]# ls "*" | tee ls.txt
ls: *: 没有那个文件或目录
[root@web ~]# cat ls.txt
[root@web ~]# ls "*" 2>&1 | tee ls.txt
ls: *: 没有那个文件或目录
[root@web ~]# cat ls.txt
ls: *: 没有那个文件或目录
[root@web ~]#
转自@http://codingstandards.iteye.com/blog/833695
转载于:https://www.cnblogs.com/xianyadan/p/6523025.html
Ubuntu tee相关推荐
- Ubuntu学习日记--Lesson8:make 21 | tee log.txt命令解析 (错误输出,重定向,管道符)
make 2>&1 | tee a.log 1. make是什么? make是linux下一个非常强大的命令,简单点就是你要编译你的源代码就得靠他了. 2. 2>&1是什么 ...
- 在Ubuntu 14.04 64bit上安装MongoDB并测试
临时需要使用python来操作mongoDB, 网上搜索发现很多文档都已经非常陈旧了, 并不符合目前3.0版本的安装配置, 特此自己整理一下, 以作备忘. MongoDB简介 MongoDB(http ...
- Ubuntu 上创建常用磁盘阵列
RAID(Redundant Array of Independent Disk 独立冗余磁盘阵列)技术是加州大学伯克利分校1987年提出,最初是为了组合小的廉价磁盘来代替大的昂贵磁盘,同时希望磁盘失 ...
- ubuntu环境ceph配置入门(一)
为什么80%的码农都做不了架构师?>>> 环境:ubuntu server 14.04 64bit,安装ceph版本0.79 正常情况下应有多个主机,这里为了快速入门以一台主机 ...
- Ubuntu上五款搜索工具:Albert、Synapse、Utools、Ulauncher、FSearch
1. 应用概览 应用 / 功能 查找应用 查找文件 查找网页 扩展程序 Albert ✓ ✓ ✓ - Synapse ✓ ✓ - - Utools ✓ ✗ ✓ ✓ Ulauncher ✓ ✓ ✓ ✓ ...
- 在 Ubuntu 上安装最新版本的 Erlang方法介绍
Erlang 是一种用于构建大规模可扩展实时系统的函数式编程语言.Erlang 最初是由 爱立信 创建的专有软件,后来被开源. Erlang 在 Ubuntu 的 Universe 仓库 中可用.启用 ...
- Ubuntu常用命令大全[显示桌面]
Ubuntu常用命令大全 查看软件xxx安装内容 #dpkg -L xxx 查找软件 #apt-cache search 正则表达式 查找文件属于哪个包 #dpkg -S filename apt-f ...
- 【问题收录】Ubuntu(14.04)那些我遇到的各种事
1."启动会话失败"的解决方法 1.1问题描述 在登录的时候输入密码总是出现启动会话失败的提示 1.2 解决方案 按住 ctrl + Alt + F1 进入到tty 输入你自己的用 ...
- 从零开始在ubuntu上安装和使用k8s集群及报错解决
文章目录 安装docker 安装kubernetes 配置k8s集群 配置虚拟机网络 配置Master节点的k8s网络 拉取k8s需要的镜像 启动 kubeadm 和 kubelet 配置 node节 ...
最新文章
- 15.1 集合的迭代器
- python drop_duplicates_Pandas drop_duplicates方法不起作用
- java线程interu_Intel 10nm服务器U首曝:多线程性能提升118%
- 请编写一个程序,用于统计字符串中每个字母的出现次数(字母忽略大小写),统计出结果后,请按照{'a':3,'b':2}的格式输出。
- 页面跳转与重定向(之二)
- java B2B2C Springboot仿淘宝电子商城系统(六)springboot整合mybatis
- Zabbix---3 监控主机内存使用率
- Python unittest –单元测试示例
- 请求的资源不可用html,“HTTP状态404请求的资源不可用”
- 2009无线通信五大趋势 3G范围将覆盖全球
- PCAN-Explorer5安装教程
- 使用docx4j在线word转换pdf及替换文本域
- 沙场秋点兵(完整版)
- Java主流框架的介绍
- UG NX二次开发(C#)-分析-测量体对象的体积
- nginx的配置优化
- 工具推荐:用VS code 导出、导入和运行Excel中的VBA代码
- 《天道》解读三:什么是天道?
- AA Master考试认证笔记
- AWT/SWT/SWING 区别和联系
热门文章
- bat脚本 -- 初步接触
- lLinux编程大全
- 新装 Asterisk-1.6 没有 Meetme
- 护士如何预防职业病:下肢静脉曲张-健康小常识
- 看〈走出软件作坊〉浅谈扁平化管理
- Linux下发生段错误时如何产生core文件-转
- 手把手教你玩转网络编程模型之完成例程(Completion Routine)篇(上)-转
- mysql5.5默认引擎_InnoDB 作为默认存储引擎(从mysql-5.5.5开始)
- eclipse中variable references non-existion resource可能原因及解决方案
- 解决linux下javac -version和java -version版本显示不一致