LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-06-2011, 04:07 PM   #1
landog
LQ Newbie
 
Registered: Jan 2006
Posts: 23

Rep: Reputation: 0
copy files less than 7 days old


I have searched for a way to copy file less than X days old and I found this:

http://www.howtogeek.com/howto/ubunt...days-on-linux/

The syntax for deleting files less than 7 days old would be like this:

find /path/to/files* -mtime -7 -exec rm {} \;

I would like to copy the files to \mnt\nas, and I'm not sure what the syntax should be.

Would this work?

find /path/to/files* -mtime -7 -exec cp {} \mnt\nas\ \;

Thanks for your help!
-dog
 
Old 05-06-2011, 04:11 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by landog View Post
Would this work?

find /path/to/files* -mtime -7 -exec cp {} \mnt\nas\ \;
Yes. It should work, except that paths in linux require a slash as delimiter (not a backslash). This should be better:
Code:
find /path/to/files* -mtime -7 -exec cp {} /mnt/nas/ \;
 
1 members found this post helpful.
Old 05-06-2011, 06:07 PM   #3
landog
LQ Newbie
 
Registered: Jan 2006
Posts: 23

Original Poster
Rep: Reputation: 0
Thanks!

Last edited by landog; 05-06-2011 at 06:14 PM.
 
Old 05-06-2011, 08:47 PM   #4
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,299

Rep: Reputation: 102Reputation: 102
Thumbs up

Quote:
Originally Posted by landog View Post
Thanks!
Glad it worked for you.
Please mark this thread as SOLVED. Follow my signature if in case you find any difficulties.
 
  


Reply


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
Shell script to copy all folders older than 7 days from Linux to Windows by samba blackthu80 Linux - General 4 03-17-2011 12:29 AM
[SOLVED] Command to copy files older than <n> days keeping dir structure. MoonMan89 Linux - General 4 07-15-2010 10:28 PM
dd copy running for 4 days, can i check status somehow? rwreed Linux - Newbie 10 02-25-2009 09:27 PM
Script help - delete files older than 45 days but exclude the system files jojothedogboy Linux - Software 3 06-13-2008 03:43 PM
which files have modified in the last few days ? varun_saa Mandriva 6 03-10-2007 10:34 AM


All times are GMT -5. The time now is 04:03 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration