1

The answers to this question show us how to redirect standard output and standard error to two separate files.

But what if I also want to see the output on the console as it is created?

We can use tee to save one of the streams to a file, but then with the other stream, we must either echo it or save it to a file.

$ command 2>error.log | tee output.log

How can I use tee on both streams?

Community
  • 1
  • 1
joeytwiddle
  • 29,306
  • 13
  • 121
  • 110

1 Answers1

1

I found the answer here.

$ ( command 2>&1 1>&3 | tee error.log >&2 ) 3>&1 | tee output.log
Community
  • 1
  • 1
joeytwiddle
  • 29,306
  • 13
  • 121
  • 110
  • 3
    If you found the answer in another question, you should just mark this as a duplicate. – Barmar Jan 23 '14 at 04:06
  • +1 Pretty sure this specific answer is more useful/easy to understand for what most users want to redirect to another fd for. And obviously answer's OP's own question, though maybe still a duplicate. – Reinstate Monica Please Jan 23 '14 at 05:19