LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-22-2003, 09:47 AM   #1
dman65
Member
 
Registered: Sep 2003
Posts: 61

Rep: Reputation: 15
Copying files from a specific date


Can anyone tell me how to copy files from a directory that have been changed either on a specific date or preferably between two dates and times.

I want to be able to backup all of the files that change within a particular directory on an hourly basis. If I could somehow specify copy every file changed from 9/22/2003 09:00:00 to 9/22/2003 10:00:00 that would be great. If that is not possible, the ability to just copy every file that was changed or created on 9/22/2003 would suffice.

I have checked the documentation on the CP command, but it doesn't appear to have any kind of date range parameter.

Thanks for any help.
 
Old 09-22-2003, 10:06 AM   #2
LarryDoliver
Member
 
Registered: Mar 2003
Posts: 126

Rep: Reputation: 17
become friends with find. Something like:
find /home/larry -atime 7 -exec cp {} /var/backup \;

should get you started. That grabs files from /home/larry that are less than 7 days old and copies them to /var/backup

get more clever with:
find /home/larry -atime 17 ! -atime 7 cp {} /var/backup \;

to get files between 1 and 2 weeks old...
 
Old 09-22-2003, 10:13 AM   #3
dman65
Member
 
Registered: Sep 2003
Posts: 61

Original Poster
Rep: Reputation: 15
Many thanks Larry.
 
Old 09-22-2003, 10:16 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
find is your 'friendly' linux tool to use.

An example: List files in current dir that are
1) older then 3 days [-mtime +3]
2) younger then 7 days [-mtime -7]
3) only in current dir [-maxdepth 1]
4) only regular files [-type f]
5) show hits in long ls format [-exec ls -l {} \;]

find . -mtime +3 -mtime -7 -maxdepth 1 -type f -exec ls -l {} \;

Guess you can work out a solution with this info.

See man find for more great options (-mtime uses days, -mmin does the same thing with minutes).

*edit*
Sigh....... I'm to slow
*edit*
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete/move/copy files of specific date imsajjadali Red Hat 26 11-07-2013 11:34 PM
copying files(s) in c climbingmerlin Programming 7 10-27-2005 02:00 PM
Copying FIles Casper12 General 4 08-07-2005 04:30 PM
copying files neozero62 Linux - Newbie 1 11-23-2003 05:38 PM
Copying Files... viperquest Linux - Software 3 03-07-2003 02:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration