centos的tee命令


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM