tee 多重定向
1.命令功能
tee读取标准输入的数据,并将内容输出成文件。
2.语法格式
tee option file
tee [-ai] 文件
参数说明
参数 |
参数说明 |
-a |
追加到文件后面,非覆盖 |
-i |
忽略中断信号 |
3.使用范例
范例1
[root@localhost ~]# who |tee who.txt root pts/0 2018-04-25 04:04 (172.16.2.100) root pts/1 2018-04-25 04:04 (172.16.2.100) root pts/2 2018-04-25 04:05 (172.16.2.100) [root@localhost ~]# cat who.txt root pts/0 2018-04-25 04:04 (172.16.2.100) root pts/1 2018-04-25 04:04 (172.16.2.100) root pts/2 2018-04-25 04:05 (172.16.2.100)
范例2
[root@localhost ~]# ps |tee -a who.txt PID TTY TIME CMD 1445 pts/0 00:00:00 bash 3638 pts/0 00:00:00 ps 3639 pts/0 00:00:00 tee [root@localhost ~]# cat who.txt root pts/0 2018-04-25 04:04 (172.16.2.100) root pts/1 2018-04-25 04:04 (172.16.2.100) root pts/2 2018-04-25 04:05 (172.16.2.100) PID TTY TIME CMD 1445 pts/0 00:00:00 bash 3638 pts/0 00:00:00 ps 3639 pts/0 00:00:00 tee