Tutorial: Use of the shell 'xargs' command

I have found the ‘xargs’ command line utility to be very useful sometimes.  Often you can avoid writing a special shell script to perform a task by using xargs to perform a task on a list of files.  Its use can best be described through an example.  I have recenlty be migrating files from one svn repository to another.  I began by copying all of the files over using rsync.  This copied all of the .svn files from the old repository, which I didn’t want.  This left me with at least 30 directories, each with a .svn directory that needed to be removed.  What to do?  Use xargs.  Here is the command:

command-prompt> find -name .svn | xargs rm -rf

This uses the find command to generate a list of all files and directories names ‘.svn’ (case sensistive).  This list is then piped to the xargs command, which runs ‘rm -rf’ on each file in the list.  That’s it!  Note that as this command is written it will seach the current directory and all subdirectories for files with name ‘.svn’.  If you want to have ‘find’ search a directory other than the current directory you can add the path of that directory after the file name to search for.  See the man page for find for more info.

Tutorial: Emacs and GDB

I remember learning how to use a debugger and Utah State University as an undergraduate.  We learned to program in Fortran 90, and used a Microsoft debugger.  It seemed cool, but honestly with the types of programs I was writing at the time, using print statement seemed to be effective enough and less of a hassle.  Recently I have been working with the Uintah MPM code, which is MUCH larger and more complex than any code I’ve ever written.  After several months of wading through the code I finally came across a problem that “cout” just could not help me solve.  The code was suddenly crashing with an allocation error and giving no useful backtrace information.  A colleague suggested that I use gdb to find out where the problem was occurring.  It turned out to be very, very helpful and surprisingly easy to use.  I’ve recently become a convert to Emacs, and found that the gdb interface in Emacs is especially nice.  So here is goes:

Continue reading