Redirecting bash stdout/stderr to two places?

You can use a named pipe, which is intended for exactly the situation you describe.

mkfifo some_pipe
command_that_writes_to_stdout | tee some_pipe \
  & command_that_reads_from_stdin < some_pipe
rm some_pipe

Or, in Bash:

command_that_writes_to_stdout | tee >(command_that_reads_from_stdin)

Leave a Comment