使用tee重定向stdin和stdout并保留以前的std

时间:2013-06-02 19:44:50

标签: bash shell

如何使用tee的管道写入文件并显示到屏幕?

这个命令实际上是这样做的,问题是它写入一个新文件而tail -f给我一个错误“截断文件”。

ls -al | tee file.txt

1 个答案:

答案 0 :(得分:0)

你正在寻找

-a tee选项

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

所以你的行将是:

ls -al | tee -a file.txt