If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):
From: John-Paul Stewart <jpstewart@sympatico.ca> Subject: Re: How to clone a directory structure? References: <cc8eda1b.0212281408.2826ec45@posting.google.com> <XPrP9.486238$P31.> <cc8eda1b.0212290326.5a2bca34@posting.google.com> <3b305d66f51187b8f35a675255dd908a@remailer.privacy.at> <cc8eda1b.0301010544.6b47651f@posting.google.com> Date: Wed, 01 Jan 2003 11:39:05 -0500 Martin Gross wrote: > > Anonymous <nobody@remailer.privacy.at> wrote in message news:<3b305d66f51187b8f35a675255dd908a@remailer.privacy.at>... > > Martin Gross <mazze@writeme.com>: > > > Need tool to create the clone structure, thanks for the idea. > > > However, that's not the main problem. Main issue is about maintaining > > > the clone, i.e. in case I erase a directory inside the source/parent > > > tree, it should be deleted with the next "clone update" in the clone > > > tree as well. > > > > 'rsync' is the tool for this job. > > > > (script with find and rsync snipped) > > Cool, that's really what I needed. I will first need to look into how > performance is - for the first steps the $filelist is a 6MB file with > some 60.000 file listings ;-) In the final application it should end > up with somewhere around 1/3 to 1/2 of that and I am not really sure > about the performance yet ;-) A simple argument such as --dirs-only > would probably be better, but seems not available. What about something like:
#!/bin/sh # clone a directory stucture (no files copied) # derived from a script by another poster f=/your/source/directory t=/your/destination/directory dirlist=/tmp/dirs mkdir -p $t cd $f # get the names of all directories and remove the initial ./ part find . -type f | sed 's@^\./@@' > $dirlist rsync -v -rlpogDt --delete --force --exclude-from=$dirlist . $t rm $dirlist The script is untested; use it at your own risk. All I've done is change the 'find' parameters to find and list the directories _only_. Then I've changed the 'rsync' parameters to include only those (rather than excluding 6MB of filenames). Again, this script is untested and is intended only to demonstrate the concept.
/Bofcusm/1926.html copyright 1997-2004 (various authors) All Rights Reserved
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar