What does 2>&1 | tee mean? I read the answer by @grg to question “brew formula” installation logs:


  brew install &lt;formula&gt; 2&gt;&amp;1 | tee install.log


So where exactly is this install.log file going to end up, and what exactly the 2&gt;&amp;1 | tee part of the command mean?
The tee command prints the piped stdout to the file path given as well as displaying it in the terminal. This is commonly used for recording the output of commands to file which would otherwise only be ephemerally printed to the terminal.

Without tee and using simple redirection of brew install &gt; install.log would prevent stdout being printed to the terminal as well as the file, requiring the file to be accessed to view the messages.
2&gt;&amp;1 redirects stderr to stdout alongside the existing stdout, meaning that the error messages are redirected as normal output.

Without this, tee would only print stdout without the error messages to the install log.


install.log is relative to the current directory.