Linux tee命令用於讀取標准輸入的數據,並將其內容輸出成文件。
tee默認覆蓋源文件 tee -a不覆蓋
[root@centos7 2019-08-17]# echo "1"|tee test.txt
1
[root@centos7 2019-08-17]# cat test.txt
1
[root@centos7 2019-08-17]# echo "2"|tee test.txt
2
[root@centos7 2019-08-17]# cat test.txt
2
[root@centos7 2019-08-17]# echo "3"|tee -a test.txt
3
[root@centos7 2019-08-17]# cat test.txt
2
3
應用場景
1:
記錄文件名並且顯示具體數量
ls *.html|tee output.txt |wc -l
2:
記錄ping包
ping -c4 baidu.com |tee -a test.txt
3:
追加多個文件
ping baidu.com | tee output1.txt output2.txt output3.txt