How many times have you given a build using a Makefile for a project, which takes a long time and also invokes other Makefiles resulting in huge amount of output on the screen ? It is good that today's Linux terminal scrolling buffer size can be adjusted, yet setting the size to 5000 or 10000 lines would end up in high RAM usage.



There is an easier way around this just by redirect the output to a file :

make > my_build_log

This would redirect only stdout(1) and not stderr(2).


The following command would solve this problem:

make 2>&1 >my_build_log

So we redirect stderr to stdout and then redirect stout (which now contains output of stderr as well) to a file.


When you do this, you notice nothing is displayed on the screen, since everything goes into the file. This is where the tee command comes to the rescue :

make 2>&1 | tee my_build_log

The output of the make command from stdout and stderr is piped to tee. tee copies the output into my_build_log not just acting as a redirection, hence we're able to see the output on the screen.

NOTE: 1, 2 mentioned for stdout and stderr are standard UNIX/Linux file descriptors for the same.