分享

linux命令之tee

 liang1234_ 2018-01-10
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 



    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多