Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How to redirect standard output to multiple log files Following seems to be not working. Any help is appreciated.

some_command 1> output_log_1 output_log_2 2>&1

share|improve this question
With zsh, you can use some_command >output_log_1 >output_log_2. –  jofel Jun 21 '12 at 8:36
You should work on you acceptance rate and accept answers to your questions. –  Ulrich Dangel Jun 21 '12 at 8:46
add comment

2 Answers

Let's say we have a function:

cmd() {
    echo hello world!

To redirect the output from cmd to two files, but not to the console, you can use:

cmd | tee file1 file2 >/dev/null

This will also work as well:

echo $(cmd) | tee file1 file2 >/dev/null

This works for me in bash on Ubuntu 12.04. Hope it helps.

share|improve this answer
add comment

Something like that

echo test | tee file1 file2 file3
share|improve this answer
can the stderr be also redirected in more than one file? –  fromnaboo Jun 23 '12 at 9:07
Yes, it can be done by virtue of redirection: find / -name test 2>&1 | tee file1 file2 file3 –  akond Jun 23 '12 at 18:27
thank you akond. –  fromnaboo Jun 23 '12 at 18:37
@akond, cmd 2>&1 | tee log1 log2 I tried executing like above, but i need to press ctrl-c to redirect it to second log file. also the output is printed on the console. I want command output to be redirected to logs but not on the console. any help is appreciated. –  doubledecker Jun 25 '12 at 10:34
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.