LinuxQuestions.org
Review your favorite Linux distribution.
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 05-31-2010, 09:56 AM   #1
dormant
LQ Newbie
 
Registered: May 2003
Posts: 19

Rep: Reputation: 0
rsync and find - how do I get the paths right?


I have a problem using rsync and find together.

I want to use find to create a file list for rsync to use with the --files-from option. I need to do this because the files can be moved from the target directory at a later date, but may remain in the source directory. I can't get find to generate the right paths for rsync.

Here's a fragment of my bash script:

Quote:
RSYNC="/usr/bin/rsync --archive --size-only --verbose"
find ${SOURCE} -mtime -7 > /tmp/rsync_files
${RSYNC} --files-from=/tmp/rsync_files / ${TARGET}
This recreates the full path under TARGET.

If I do this:
Quote:
${RSYNC} --files-from=/tmp/rysnc_files ${SOURCE} ${TARGET}
This can't find the source files.

I need find to return the partial paths starting at the SOURCE directory, but can't see an easy way to do this.
 
Old 05-31-2010, 10:15 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
What does the path in your ${SOURCE} variable look like? Find seems to build it's output based on the directory string used. If you use an absolute path the output will have an absolute path, but if you use a relative one, it will have a relative path.

Another thing to look at, assuming you're using the GNU version of find, is the -printf option. It will allow you to format the output in various ways, so you might be able to build an appropriate output string with it.

Finally, you might want to simply use sed on your output file to change the paths to the format you want.
 
Old 05-31-2010, 10:23 AM   #3
dormant
LQ Newbie
 
Registered: May 2003
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks for the suggestions.

I actually just did it by cding to the source directory, then using "find .".

But I have another problem. Even though I now pass the file list to rsync, it tries to sync all the files in the source directory.
 
  


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
find: paths must precede expression lead2gold Linux - General 11 02-27-2014 07:06 AM
[SOLVED] rsync two directories, slashes at ends of paths or not anon091 Linux - Newbie 3 10-23-2009 03:25 PM
Problem with find: paths must precede expression troelskn Programming 11 07-29-2009 02:48 AM
Algorithm to find paths xeon123 Programming 5 04-24-2007 02:18 AM
Wine can't find paths in Mandriva 2005 LE kalahari875 Mandriva 3 06-28-2005 07:22 AM

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

All times are GMT -5. The time now is 01:40 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
Open Source Consulting | Domain Registration