LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   copy by date (https://www.linuxquestions.org/questions/linux-newbie-8/copy-by-date-802388/)

virtual memory 04-16-2010 08:04 AM

copy by date
 
hi all,
thanks for great of forums linuxquestions.org
i just need to make copy files have 2 year old to another directory
i know how to use cp command but i am not able to do that

please any help!

thanks in advance for your help

PMP 04-16-2010 08:14 AM

First find the files

Code:

man find
use xargs or exec to copy it to another directory

rayfordj 04-16-2010 08:21 AM

Something like this should do it. Might want to test it somewhere "safe" first. ;)

Code:

find /old/file/dir/ -mtime +730 -exec cp {} /new/copy/dir/ \;
Where /old/file/dir/ is the directory where the files you want to copy are located and /new/copy/dir/ is the location to place the copy. -mtime is for the files' last modified time. The value 730 was calculated by multiplying 365 days/yr by 2 years. The +730 indicates to find files older-than the value specified.

For more details and information on find, consult its manual and info pages. It can be quite useful.

:study:


All times are GMT -5. The time now is 08:48 AM.