Random Shell Tricks

This is quite boring… just a list of useful shell commands that I’m sure I’ll need again sometime.

  • Find files/directories in a specified date range, do something to them; base this on the top level only, not traversing into each subdirectory.

    find ./* -prune -newermt 1/1/2010 -not -newermt 1/1/2011 -exec mv {} ../2010/ \;

    will move all files/directories with modification times in 2010 to a directory one level up, called 2010. I use this to clean up a download/scratch/temp directory (I should just delete the files, but just in case, I organize them into yearly folders).