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