linux tee 命令

tee 重定向输出到多个文件
在执行Linux命令时,我们 既想把输出保存到文件中,又想在屏幕上看到输出内容,就可以使用tee命令
要注意的是:在使用管道线时,前一个命令的标准错误输出不会被tee读取。
$  man tee
NAME
       tee - read from standard input and write to standard output and files

SYNOPSIS
       tee [OPTION]... [FILE]...

DESCRIPTION
       Copy standard input to each FILE, and also to standard output.

       -a, --append
              append to the given FILEs, do not overwrite

       -i, --ignore-interrupts
              ignore interrupt signals

       --help display this help and exit

       --version
              output version information and exit

       If a FILE is -, copy again to standard output.

常见用例:
tee file     //覆盖

tee -a file    //追加

tee -        //输出到标准输出两次
tee - -    //输出到标准输出三次

tee file1 file2 -    //输出到标准输出两次,并写到那两个文件中

ls | tee file   

另:把标准错误也被tee读取
ls "*" 2>&1 | tee ls.txt 

原文地址:http://blog.csdn.net/williamwang2013/article/details/8550178

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值