Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-16-2010, 09:04 AM   #1
virtual memory
LQ Newbie
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
copy by date

hi all,
thanks for great of forums
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

Last edited by virtual memory; 04-16-2010 at 09:06 AM.
Old 04-16-2010, 09:14 AM   #2
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
First find the files

man find
use xargs or exec to copy it to another directory
Old 04-16-2010, 09:21 AM   #3
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
Something like this should do it. Might want to test it somewhere "safe" first.

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.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Copy by date ijf99 Linux - Newbie 1 12-17-2008 06:10 AM
copy based on date Byenary Linux - General 2 03-02-2007 05:13 PM
CLI copy files by date linuxhippy Slackware 2 06-23-2006 10:01 PM
Copy files after a certain date davholla Linux - General 2 03-17-2005 10:29 AM
Date-based copy AdmiralThrawn Linux - General 2 02-23-2004 10:03 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:12 PM.

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