[Gllug] Flat rsync

Jose Luis Martinez jjllmmss at googlemail.com
Thu Jul 10 21:13:03 UTC 2008


On Thu, Jul 10, 2008 at 4:52 PM, Stephen Nelson-Smith
<sanelson at gmail.com> wrote:
> Hi,
>
> I have a filesystem with a number of subdirectories and files inside each one.
>
> I want to rsync all the files from that filesystem to a machine
> somewhere else, but on the destination machne all I want is all the
> files in one place - I don't want to replicate the directory structure
> - just all the files.
>
> 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
---

you have to take care of files with special characters in their names
(like spaces, a topic that was discussed a few days ago), put some
extra logic if you want to check for files that may overwrite each
other and how to handle links, but something like the above would be
the core of a script to work all this out for you.

>
> S.
> --
> Gllug mailing list  -  Gllug at gllug.org.uk
> http://lists.gllug.org.uk/mailman/listinfo/gllug
>
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list