如何将命令的输出重定向到两个文件 [英] how to redirect a output of a command to two files

查看:116
本文介绍了如何将命令的输出重定向到两个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将命令的输出重定向到两个文件,如file1和file2
file1是一个新文件,file2是已经存在的文件,我需要附加输出
i已尝试

i need to redirect a output of a command to two files say file1 and file2 file1 is a new file and file2 is already existing file where i need to append the output i have tried

这不会给出预期的结果:

This is not giving the expected results:

command > file1 > file2


推荐答案

您正在寻找 tee 命令。

You are looking for the tee command.

$ echo existing >file2
$ date | tee file1 >> file2
$ cat file2
existing
Mon Mar  9 10:40:01 CET 2009
$ cat file1
Mon Mar  9 10:40:01 CET 2009
$

这篇关于如何将命令的输出重定向到两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆