[Gllug] Flat rsync

Bruce Richardson itsbruce at workshy.org
Fri Jul 11 10:31:30 UTC 2008


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:
> ---
> #!/bin/ksh
> find . -type f | while read file
> do
> mv "$file" /flat_directory
> done
> ---

This still doesn't solve the problem of files with the same name.  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.

-- 
Bruce

Remember you're a Womble.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20080711/5e1d8a89/attachment.pgp>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list