tee 读取标准输入数据,并输出成文件

作用

tee 命令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件。

语法

tee [-ai][--help][--version][文件...]

参数

  • -a或--append  附加到既有文件的后面,而非覆盖它.

  • -i或--ignore-interrupts  忽略中断信号。

  • --help  在线帮助。

  • --version  显示版本信息。

示例

(1)使用 tee 命令将用户输入的数据保存到 myFile 文件,如下:

[hxstrive@localhost ~]$ tee myFile
hi! www.hxstrive.com    # 输入的数据
hi! www.hxstrive.com    # 回车后 tee 命令反馈的信息
^C                      # 按 Ctrl+C 退出 tee 命令

# 查看 myFile 内容
[hxstrive@localhost ~]$ cat myFile
hi! www.hxstrive.com

(2)使用 tee 命令将用户输入的数据保存到 myFile1 和 myFile2 文件,如下:

[hxstrive@localhost ~]$ tee myFile1 myFile2
hi! www.hxstrive.com    # 输入的数据
hi! www.hxstrive.com    # 回车后 tee 命令反馈的信息
^C                      # 按 Ctrl+C 退出 tee 命令

# 查看 myFile1 内容
[hxstrive@localhost ~]$ cat myFile1
hi! www.hxstrive.com

# 查看 myFile2 内容
[hxstrive@localhost ~]$ cat myFile2
hi! www.hxstrive.com

更多关于命令详细参考手册,请使用 man 命令或者 --help 参数获取帮助信息

关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号