[NCLUG] shell scripting

J. Paul Reed preed at sigkill.com
Thu Sep 13 11:29:17 MDT 2001


On Thu, 13 Sep 2001, mike cullerton wrote:

>   i have what i believe is a simple shell scripting question. i have a
> number of files in a directory. some of them have been modified today. i
> want to copy the files that have been modified today to another directory.

Modified today as in the start of today (midnight), or the last 24 hours?

Look at the -daystart argument of find (man find), depending on your answer.

For the last 24 hours, this will do it, IF all you want to do is copy the
files (if you want to do more, you'll have to do the find, put it in an
array, and iterate through it, like the code snippet you had there):

find -ctime 1 -exec /bin/cp {} /path/to/mynewdir/ \;

You'll probably want to test this and play around with it to fit exactly
what you're doing; I didn't test it (or rather, I just used an 'echo' as
the parameter to -exec)

Later,
Paul
   ---------------------------------------------------------------------
   J. Paul Reed               preed at sigkill.com || web.sigkill.com/preed
   It's amazing what a little brain damage will do for your credibility.
                                              -- Leonard Shelby, Memento





More information about the NCLUG mailing list