语法
tee [-ai][--help][--version][文件...]
参数
- -a 附加到既有文件的后面,而非覆盖它.
- -i 忽略中断信号。
实例
使用free命令显示系统内存使用信息,并使用tee命令将信息输出到屏幕,并保存到文件mem.txt中
[root@localhost ~]# free -h | tee mem.txt
total used free shared buff/cache available
Mem: 1.8G 164M 1.2G 9.6M 387M 1.5G
Swap: 2.0G 0B 2.0G
可以写入多个文件,每个文件之间使用空格分隔
[root@localhost ~]# free -h | tee mem1.txt mem2.txt mem3.txt
total used free shared buff/cache available
Mem: 1.8G 165M 1.2G 9.6M 389M 1.5G
Swap: 2.0G 0B 2.0G
在已存在的文件底部追加内容,不再覆盖原有内容
[root@localhost ~]# free -h | tee -a mem.txt
total used free shared buff/cache available
Mem: 1.8G 165M 1.2G 9.6M 389M 1.5G
Swap: 2.0G 0B 2.0G