command-line - 如何将命令的输出重定向到两个文件

标签 command-line redirect

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

这没有给出预期的结果:

command > file1 > file2

最佳答案

您正在寻找tee命令。

$ 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
$

关于command-line - 如何将命令的输出重定向到两个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/625571/

相关文章:

windows - 远程访问 Windows 7 命令提示符

url - 使用 URL 重定向站点阻止 Telegram 链接预览

javascript - 如果没有则添加查询字符串

javascript - 重定向链接而不点击

c# - 使用 CommandLineParser 报告未知参数

c# - 如何通过 C# 传递多个命令行参数

command-line - 通过命令行在 iphone 设备中安装应用程序

linux - 如何阻止sed插入换行符?

c# - 如何发送带有查询字符串(包含 url 作为查询字符串)的 url 作为查询字符串

google-chrome - Chrome 重定向到 https