tee命令主要功能是用于读取标准输入的数据,并将其输入的内容输出到标准的输出设备中,同时将其内容保存成文件。
语法:tee [参数] [文件]
参数说明:
-a或--append:追加写入操作,而非覆盖它
-i或--ignore-interrupts:忽略中断信号
--help:显示帮助信息
--version:显示版本信息
[root@CentOS7 ~]# tee file1 file2tee commandtest.tee commandtest.^C[root@CentOS7 ~]# cat file1 file2tee commandtest.tee commandtest.
Ctrl+C结束标准输入之后,此时,可以分别打开file1和file1文件,其内容分别写入到了文件中,说明“tee”命令执行成功。
2、将某个命令执行结果输出到屏幕中,同时输入到文件中
[root@CentOS7 ~]# free -m |tee file1 total used free shared buff/cache availableMem: 1833 323 1145 12 365 1329Swap: 4095 0 4095[root@CentOS7 ~]# cat file1 total used free shared buff/cache availableMem: 1833 323 1145 12 365 1329Swap: 4095 0 4095
[root@CentOS7 ~]# cat file2aaaa[root@CentOS7 ~]# echo "bbb"|tee -a file2bbb[root@CentOS7 ~]# cat file2aaaabbb
喜欢古诗词的同学们,欢迎移步「纸间有糖」,愿这里的文字甜到你心里。