[NCLUG] shell scripting

C. J. Keist cjay at engr.colostate.edu
Thu Sep 13 11:32:40 MDT 2001


A better way:

find . -type f -mtime n -exec cp {} /destination_dir \;

The -type f will make sure you don't try and copy a directory.
Its always safe to do this first to make sure it is getting the files you 
expect

find . -type f -mtime n -print
-------------------------------------------------------------------------------------

I would simply use the "find" command.

find . -mtime n -exec cp {} /destination_dir \;

mtime is for modified time and n is true if the file has been modified in n 
days.

Hope this helps.

At 11:09 AM 9/13/01 -0600, you wrote:
>hey folks,
>
>   hope everyone and all your loved ones are well.
>
>   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.
>
>something like
>
>  for ($i in <modified today>) cp $i /some/directory
>
>i am using bash.
>
>thanks,
>mike
>
>-- mike cullerton   michaelc at cullerton.com
>
>
>_______________________________________________
>NCLUG mailing list
>NCLUG at nclug.org
>http://www.nclug.org/mailman/listinfo/nclug

C. J. Keist                     Email: cjay at engr.colostate.edu
UNIX/Network Manager            Phone: 970-491-0630
Engineering Network Services    Fax:   970-491-5569
College of Engineering, CSU
Ft. Collins, CO 80523-1301

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nclug.org/pipermail/nclug/attachments/20010913/868caf59/attachment.html>


More information about the NCLUG mailing list