tee 是将结果输入到文件中,屏幕显结果,及结果也输入到文件中。
举例:tee (一般跟管道结合一起用,用在最后)
: -a 追加内容,如果不加-a覆盖文件内容。
[root@bogon shell]# who |tee who.txt
root :0 2011-03-23 04:10
root pts/1 2011-03-23 15:01 (:0.0)
root pts/3 2011-03-23 18:46 (192.168.0.127)
[root@bogon shell]# cat who.txt
root :0 2011-03-23 04:10
root pts/1 2011-03-23 15:01 (:0.0)
root pts/3 2011-03-23 18:46 (192.168.0.127)
[root@bogon shell]#
加-a :
[root@bogon shell]# ll |tee -a who.txt
总计 72
-rwxr-xr-x 1 root root 74 03-23 04:31 1.sh
-rw-r--r-- 1 root root 140 03-23 20:17 who.txt
[root@bogon shell]# cat who.txt
root :0 2011-03-23 04:10
root pts/1 2011-03-23 15:01 (:0.0)
root pts/3 2011-03-23 18:46 (192.168.0.127)
总计 72
-rwxr-xr-x 1 root root 74 03-23 04:31 1.sh
-rw-r--r-- 1 root root 140 03-23 20:17 who.txt
[root@bogon shell]#
已经who.txt追加到这个文件中了
阅读(873) | 评论(0) | 转发(0) |