Jun 062007
 

I often want to perform a bash command on a whole collection of files, and was delighted to discover that bash has a for-loop that makes this sort of thing easy. For example, to rename all the files in the current directory with the spaces converted to underscores, execute
for ii in *; do mv -i "$ii" "${ii// /_}"; done
This bash syntax can be used in many situations, such as feeding a whole set of files through PovRay for tracing.

The bash for-loop can be also used with a numerical counting variable.
for ((i=0; i=10; i+=1)); do cp SOME_FILE SOME_FILE$i; done

Jun 062007
 

Patches provide a way to keep the Linux kernel up to date without regular large downloads. The latest kernel patches are available at kernel.org, but I had to look around to find out exactly how to use them.

Download the latest patch (for instance patch-2.6.17.7.bz2) into /usr/src/linux and make sure that the previously applied patch (patch-2.6.17.6.bz2) is in this directory also. Remove the previous patch with
bzcat patch-2.6.17.6.bz2 | patch -p1 -R
The new patch can then be applied using
bzcat patch-2.6.17.7.bz2 | patch -p1
Things can be cleaned up by renaming the source directory to reflect the lastest patch level (and fixing the symbolic link) and removing the now obsolete patch file (in this case, patch-2.6.17.6.bz2).