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

猜你喜欢

转载自www.cnblogs.com/daixubinbin/p/11370843.html
tee
今日推荐