If you are looking for the epic motorcycle journey blog that I've written, please see the Miles By Motorcycle site I put together. 
  • Useful Unix/Linux Find command
    06/28/2010 2:08PM

    One of the problems I face these days is that I do too many disparate things. As a result, some uncommon tasks take a little while to get figured out. 

    In this particular case I had a directory of photos spanning a few days. I wanted to use the dates of the photos to copy them into separate directories spanning the four days of my trip.

    You can use the Unix/Linux find command to select files that are older or newer than a given other file.

    So for instance, the directory of photos was:

    -rwxr-xr-x. 1 yml yml 4468694 Jun 24 22:25 DSC01079.JPG
    -rwxr-xr-x. 1 yml yml 4496797 Jun 24 22:34 DSC01080.JPG
    -rwxr-xr-x. 1 yml yml 4543774 Jun 24 22:34 DSC01081.JPG
    -rwxr-xr-x. 1 yml yml 3852189 Jun 24 23:00 DSC01082.JPG
    -rwxr-xr-x. 1 yml yml 3386850 Jun 25 01:41 DSC01083.JPG
    -rwxr-xr-x. 1 yml yml 4492462 Jun 25 12:14 DSC01084.JPG
    -rwxr-xr-x. 1 yml yml 4515675 Jun 25 15:07 DSC01105.JPG
    -rwxr-xr-x. 1 yml yml 3317623 Jun 25 23:02 DSC01118.JPG
    -rwxr-xr-x. 1 yml yml 3314088 Jun 25 23:02 DSC01119.JPG
    -rwxr-xr-x. 1 yml yml 3584793 Jun 25 23:04 DSC01120.JPG
    -rwxr-xr-x. 1 yml yml 3837912 Jun 26 01:11 DSC01121.JPG
    -rwxr-xr-x. 1 yml yml 3754608 Jun 26 01:11 DSC01122.JPG

    To copy the files for June 25th, one approach is to select the files that are older (i.e. NOT newer than) than DSC01120.JPG, the last photo on the 25th and newer than DSC01082.JPG, the last photo on the 24th.

    [yml@nomad 101MSDCF]$ find . -name \*.JPG  -cnewer DSC01082.JPG \! -cnewer DSC01120.JPG -exec cp {} somedirectory