栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

2021-10-19 Linux tee 命令读入标准数据然后标准输出同时把数据写入文件,可以在终端上显示的同时保存到文件。

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

2021-10-19 Linux tee 命令读入标准数据然后标准输出同时把数据写入文件,可以在终端上显示的同时保存到文件。

一、man tee ,tee - read from standard input and write to standard output and files

命令读入标准数据然后标准输出同时把数据写入文件

TEE(1)                                                                  User Commands                                                                 TEE(1)

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

       -p     diagnose errors writing to non pipes

       --output-error[=MODE]
              set behavior on write error.  See MODE below

       --help display this help and exit

       --version
              output version information and exit

   MODE determines behavior with write errors on the outputs:
       'warn' diagnose errors writing to any output

       'warn-nopipe'
              diagnose errors writing to any output not a pipe

       'exit' exit on error writing to any output

       'exit-nopipe'
              exit on error writing to any output not a pipe

       The  default  MODE  for  the -p option is 'warn-nopipe'.  The default operation when --output-error is not specified, is to exit immediately on error
       writing to a pipe, and diagnose errors writing to non pipe outputs.

AUTHOR
       Written by Mike Parker, Richard M. Stallman, and David MacKenzie.

二、我这里脚本上用到的地方。

 三、下面的截图展示了这个输出内容不仅被写入 output.txt 文件,也被显示在标准输出中。

 四、默认情况下,在同一个文件下再次使用 tee 命令会覆盖之前的信息。如果你想追加信息到文件的话,可以通过 -a 命令选项改变默认设置。

[command] | tee -a [file]

五、参考文章

技术|为初学者介绍的 Linux tee 命令(6 个例子)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/334646.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号