Bash: Pipe command output to stdout and file

If you need both stdout and stderr in a file for logging or debugging purposes, while also wanting to monitor the output of a command, you can use a pipe control operator along with tee:

$ foo |& tee out.log