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.

 

Do you have a branch checked out in your SVN and want to make an archive of only the source files and not the .svn directories ? Here is the trick.

To tar your SVN directory my_branch, go one level above and use one of the following commands based on your desired compression gzip or bzip2:

tar czvf my_backup.tgz my_branch --exclude='.svn*'

tar cjvf my_backup.tar.bz2 my_branch --exclude='.svn*'

This trick is helpful to exclude your desired patterns.

A more easier way is :

tar czvf my_backup.tgz my_branch --exclude-vcs

which would exclude all files related to the version control system, the supported ones afaik being CVS, SVN, RCS, SCCS, Mercurial and few others.

If your local copy builds few binaries like .o, .a, .so, etc. and you need to exclude them as well, you can combine --exclude-vcs with --exclude :

tar czvf my_backup.tgz my_branch --exclude-vcs --exclude='.so' --exclude='.o' --exclude='.a'

Or you can make the tar program read the exclude list from a file, adding one exclude pattern per line:

tar czvf my_backup.tgz my_branch --exclude-vcs --exclude-from=my_exclude_list

Contents of my_exclude_list:
*.so
*.o
*.a
Note: --exclude, --exclude-vcs, --exclude-from are all independent of each other and can be combined to get different results.