LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 10-29-2010, 07:31 PM   #1
brunoschwartz
LQ Newbie
 
Registered: Aug 2010
Posts: 15

Rep: Reputation: 0
script to find new files and copy them into different directories


Hello All,

I am a newbie to Linux but liking it a lot. I have a question which has been in part answered many times but nothing I found relateds completely to my situation. I am sure there will be people who will say RTFM but believe me I did, and searched as well but to no avail.

I have a situation where I want to copy files created withing last hour in one directory into another one. The problem is that that the directories are on different levels in the dir tree so the absolute path is different. But I want to keep the relative path the same.

Example:
I want to copy new files from /mnt/path_to_webdav/user to /home/user. so if there is new file /mnt/path_to_webdav/user/doc/xy.txt I want it to be copied to /home/user/doc/xy.txt. Also if there is a new dir, say /mnt/path_to_webdav/user/newdir I want a new dir to be created in /home/user/newdir with all the files in it, should there be any.

I can do find with exec and copy all the files into one directory. This is not what I want though. How do I preserve the relative path and get the files copied into their corresponding directories?

Thanks a lot for your help.
 
Old 10-29-2010, 08:38 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,896

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
rsync may be the answer to your problem.

Here's a link to an example solution. http://www.linuxdynasty.org/using-rs...es-around.html
 
  


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
Creating a script to move or copy files into multiple directories below the files matthes138 Linux - Newbie 5 08-25-2009 05:57 PM
How to copy one file and to multiple directories using shell script? cebuy Programming 8 03-31-2009 08:04 PM
Script to find duplicate files within one or more directories peter88 Linux - General 6 12-10-2006 06:17 AM
Copy files from different directories fiomba Linux - Software 3 02-11-2005 04:01 AM
find and copy files into multiple directories avargas22 Linux - Newbie 2 04-01-2004 12:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:17 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