shell 之 tee 命令,实现重定向到文件的同时仍能 通过管道 (|)传给接下来的命令
2015-10-09 23:09
597 查看
在下面的命令中 tee 收到来自 stdin 的数据 ,它将 收到的数据 一份副本写入文件 out.txt ,同时将另一份副本作为后续命令的 stdin ,cat -n 将从stdin 中接收到的每一行数据加上行号并 写入 stdout .
tee 命令默认会覆盖文件,但它提供了一 -a 选项,用于追缴内容。
我们可以将 stdin 作为命令行参数 ,只需要将 - 作为命令的文件名参数即可
例如
输出结果为
who is this
who is this
$cat a* | tee out.txt | cat -n
tee 命令默认会覆盖文件,但它提供了一 -a 选项,用于追缴内容。
$cat a* | tee -a out.txt | cat -n
我们可以将 stdin 作为命令行参数 ,只需要将 - 作为命令的文件名参数即可
例如
$echo who is this | tee -
输出结果为
who is this
who is this
相关文章推荐
- Linux Shell ssh登录脚本
- 9月13日 第十次课(01) Linux shell脚本编程基础
- lamp 架构搭建shell脚本
- Linux Shell 之 Shell 基本控制结构(二)(循环结构)
- Linux 命令 - su: 以其他用户和组 ID 的身份来运行 shell
- linux删除当前文件夹最新的前n个文件shell指令
- ADB shell之am命令,个人翻译(未完待续)
- ADB Shell Commands,个人翻译,多多指点
- shell 中echo带颜色输出
- (转)xshell基本操作步骤
- shell 函数的简单用法
- 链表——PowerShell版
- shell脚本小Demo
- Shell脚本学习第一篇
- git bash常用命名整理
- 常用上传shell脚本
- shell脚本出错而重复尝试
- Linux学习笔记之<Shell编程初入门>
- shell, python中比较两个日期的先后
- xshell常用快捷键