如何重定向到文件并将其传输到另一个应用程序?

时间:2014-01-04 02:16:34

标签: bash

现在我有:

{ /usr/bin/node server.js 2>&3 | logger -p local0.notice -t node_server } 3>&1 1>&2 | logger -p local0.err -t node_server

但是我想要标准输出和错误来转到console.log文件。我该如何添加它?

2 个答案:

答案 0 :(得分:2)

一般

program1 |& tee err_out_log.txt | program2

请注意|&是一个Bash 4功能,它结合了stderr和stdout;

答案 1 :(得分:1)

你想使用tee

$ man tee
TEE(1)                    BSD General Commands Manual                   TEE(1)

NAME
     tee -- pipe fitting

SYNOPSIS
     tee [-ai] [file ...]

DESCRIPTION
     The tee utility copies standard input to standard output, making a copy
     in zero or more files.  The output is unbuffered.