[Gllug] Flat rsync
Jose Luis Martinez
jjllmmss at googlemail.com
Fri Jul 11 20:04:44 UTC 2008
On Fri, Jul 11, 2008 at 11:31 AM, Bruce Richardson <itsbruce at workshy.org> wrote:
> On Thu, Jul 10, 2008 at 10:13:03PM +0100, Jose wrote:
>> > Any ideas how best to do this?
>> rsync everything to the 2nd machine, directory structure and all.
>> in the second machine try something like this:
>> find . -type f | while read file
>> mv "$file" /flat_directory
> This still doesn't solve the problem of files with the same name.
I didn't say it would, I explicitly mentioned that such problem
required a bit more scripting.
> A safer way to handle that would be to take a list generated by find
> on the original host and then create a unique name for each destination
> file by, for example, taking the full pathname of the original file and
> replacing each directory separator by another character (e.g. _ and of
> course you'd have to escape any _ characters already in the path.) Then
> you could feed the list of sources and destinations to rsync or scp or
> whatever is appropriate. It also has the benefit that you could
> recreate the original directory structure if desired.
You can get the file name expunged from $file , then with an if
statement check if the file exists, if it does rename one of them.
But I am all for knowing your data first. If you know there are no
repeat names you need a simpler script and forget about doing too much
> Remember you're a Womble.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> -----END PGP SIGNATURE-----
> Gllug mailing list - Gllug at gllug.org.uk
Gllug mailing list - Gllug at gllug.org.uk
More information about the GLLUG