tee命令

tee命令

tee命令可以把数据流同时重定向到文件和屏幕。


语法:

数据流  |  tee [选项]  [文件]


选项:

不加选项:覆盖重定向

-a:追加到文件


实例:

覆盖重定向。

[root@localhost ~]# head -n 2 /etc/passwd | cut -d ":" -f 1-3 | tee 1.txt

root:x:0

bin:x:1

[root@localhost ~]# cat 1.txt

root:x:0

bin:x:1

追加重定向。


[root@localhost ~]# head -n 2 /etc/passwd | cut -d ":" -f 1-3 | tee -a 1.txt

root:x:0

bin:x:1

[root@localhost ~]# cat 1.txt

root:x:0

bin:x:1

root:x:0

bin:x:1


猜你喜欢

转载自blog.51cto.com/11060853/2107284
tee