The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
overwrite specific lines in a file csecnarf Shell Programming and Scripting 7 05-13-2008 08:01 AM
how to print struct in GDB useless79 High Level Programming 4 09-06-2007 05:02 AM
Overwrite & Delete in Text File 33junaid Shell Programming and Scripting 11 08-16-2007 02:28 AM
overwrite problem ali999 UNIX for Dummies Questions & Answers 2 03-23-2005 11:43 PM
Overwrite Duckman UNIX for Dummies Questions & Answers 9 03-26-2001 10:27 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-27-2005
Registered User
 

Join Date: Oct 2005
Posts: 1
a script to clone a dir tree, & overwrite the dir struct elsewhere?

hi all,

i'm looking for a bash or tcsh script that will clone an empty dir tree 'over' another tree ...

specifically, i'd like to:

(1) specify a src directory
(2) list the directory tree/hiearchy beneath that src dir, w/o files -- just the dirs
(3) clone that same, empty dir hierarchy to a NEW OR EXISTING specified dir target, creating dirs/subdirs as necessary
(4) all ORIG dir ownership/perms should be preserved/corrected in the target tree

any obvious/existing solutions? i'd have thought this exists already somewhere ...

thx!

richard
Reply With Quote
Forum Sponsor
  #2  
Old 11-18-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Check out this post - Copying a Directory Structure to a new structure
Reply With Quote
  #3  
Old 11-19-2005
Registered User
 

Join Date: Nov 2005
Location: London
Posts: 14
Lightbulb

Hi Richard,

The tar command can be used to reproduce a directory tree with all the ownership and permissions preserved (though arbitary preserved ownership is only possible if you untar as root).

By combining with the find and xargs command it is possible to tar a directory tree with none of the files in it saved.

To make the compacted tree, use this command from the directory root you want to copy the tree from...

find . -type d -print0 | xargs -0 tar -f tree.tgz --no-recursion -zpc

This creates a file called tree.tgz. Copy this file to the directory you want to copy the tree to then just type...

tar zxf tree.tgz


I recommend testing this in an empty directory before letting it loose on a source tree just to make sure it creates the tree in the way you expect e.g. at the right directory level.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 01:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0