两次重定向输出

两次重定向输出

我想从命令行两次重定向我的输出

例如:

comp.reg $T_GDS_MASTER/bin.new $T_GDS_MASTER/bin.old > $T_GDS/log/comp.reg.out 2>&1

我想要将该命令也打印到屏幕上。我该怎么做?

答案1

您要查找的命令是tee。完整语法是这里

答案2

看一下 tee——从标准输入读取并写入标准输出和文件。脚本——制作终端会话的打字稿——也许也感兴趣。

答案3

球座是一个身份过滤器,它可以将结果输出到 stdout 并保存:

tee

Redirect output to multiple files, copies standard input to standard 
output and also to any files given as arguments. This is useful when you 
want not only to send some data down a pipe, but also to save a copy.

Syntax
      tee [options]... [file]...

Options
   -a
   --append
        Append standard input to the given files rather than overwriting
        them.

   -i
   --ignore-interrupts'
        Ignore interrupt signals.

Example:

   ps -ax | tee processes.txt | more

If a file being written to does not already exist, it is created.
If a file being written to already exists, the data it previously 
contained is overwritten unless the `-a' option is used.

相关内容