Tag Archives: terminal

Exclude svn files while copying in linux

SVN recursively populates .svn folders in all the children folders of a project under version control. There are a number of techniques to copy the parent folder without copying the .svn folders and files, but I find the following to be easiest and quickest.

amit@texens:~$ rsync -aC /path/to/srcdir/ /path/to/destdir

The trailing “/” on srcdir is to make sure that the contents of srcdir are copied to destdir. Without the trailing “/”, the destdir will contain the srcdir and everything will be one more level down.

One other option is to copy the directory without paying any heed to the .svn directories and then find and delete all the .svn folders using the following command.

amit@texens:~$ cp -r /path/to/srcdir/folder /path/to/destdir
amit@texens:~$ find /path/to/destdir -name '.svn' -exec rm -r {} \;


Redirecting Output from Terminal to a file

Today, I was trying to get a scheduler simulator up and running. The source code had a Makefile which was doing quite some job. I tried to do a make only to end up with a lotta errors. The list of errors was so long that the terminal didn’t show up the entire error by scrolling up. I tried to redirect it to a text file using

$ make | tee filename.txt

But, instead of getting the errors, what I got was the entire make command after getting proccessed. I was interested in the errors rather than what the make command was.
I used this useful feature called script. All you gotta do is run the script command before you start.

$ script

You’ll get the prompt

$ Script started, file is typescript

This is the system’s way of telling that the system is recording everything going on the terminal
Once you’re done recording, just type the exit command

$ exit

And tada… its done, the terminal tells you

$ Script done, file is typescript

Everything goes into the file ‘typescripit’ which is created into the current directory.
For details checkout the manpages for script

$ man script