RE: [SLE] Duplicating a directory structure
-----Original Message----- From: Jerry Feldman [mailto:gaf@blu.org] Sent: Thursday, July 27, 2006 2:48 PM To: suse-linux-e@suse.com Subject: Re: [SLE] Duplicating a directory structure
On Thursday 27 July 2006 2:11 pm, Marlier, Ian wrote:
I need to duplicate a directory structure on a SuSE 10.0 box -- not
files, just the directory tree.
I thought this would be pretty simple, using find, but I'm running into big issues because many (as in almost all) of the directories have spaces in their names. For the life of me I can't get the silly
the thing
to put everything where it should be.
The current directory structure is something like the following: /tmp/origin /tmp/origin/folder one Use the cp(1) command with the -r (recursive) option. Note that -p also preserves permissions. Alternatively, rsync or even tar: cd /tmp mkdir /tmpdup tar cf - . | (cd /tmpdup;tar xf -)
Hrm...except that those are going to bring the files with them -- I just want an empty directory tree. Is there a flag for either tar or cp that tells it to only see/move directories, and not files? -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
On 7/27/06, Marlier, Ian
-----Original Message----- From: Jerry Feldman [mailto:gaf@blu.org] Sent: Thursday, July 27, 2006 2:48 PM To: suse-linux-e@suse.com Subject: Re: [SLE] Duplicating a directory structure
I need to duplicate a directory structure on a SuSE 10.0 box -- not
files, just the directory tree.
I thought this would be pretty simple, using find, but I'm running into big issues because many (as in almost all) of the directories have spaces in their names. For the life of me I can't get the silly
to put everything where it should be.
The current directory structure is something like the following: /tmp/origin /tmp/origin/folder one Use the cp(1) command with the -r (recursive) option. Note that -p also
On Thursday 27 July 2006 2:11 pm, Marlier, Ian wrote: the thing preserves permissions. Alternatively, rsync or even tar: cd /tmp mkdir /tmpdup tar cf - . | (cd /tmpdup;tar xf -)
Hrm...except that those are going to bring the files with them -- I just want an empty directory tree.
Is there a flag for either tar or cp that tells it to only see/move directories, and not files?
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Go back to trying find. I think something like this should work, but it is only lightly tested. newdir="My-new-target-directory"; find . -type d -print0 | (mkdir $newdir; cd $newdir; xargs -0 mkdir -p) The print0 causes each pathname to be terminated by a null. The -0 for xargs causes it to look for the null as an argument seperator. Greg -- Greg Freemyer The Norcross Group Forensics for the 21st Century -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
On Thursday 27 July 2006 13:51, Marlier, Ian wrote:
cd /tmp mkdir /tmpdup tar cf - . | (cd /tmpdup;tar xf -)
Hrm...except that those are going to bring the files with them -- I just want an empty directory tree.
Is there a flag for either tar or cp that tells it to only see/move directories, and not files?
rsync has the --dirs option: -d, --dirs Tell the sending side to include any directories that are encountered. Unlike --recursive, a directory's contents are not copied unless the directory was specified on the -------------- command-line as either "." or a name with a trailing slash (e.g. "foo/"). -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Hrm...except that those are going to bring the files with them -- I just want an empty directory tree.
Is there a flag for either tar or cp that tells it to only see/move directories, and not files? Try this. I had forgotten about cpio. This works including copying
On Thursday 27 July 2006 2:51 pm, Marlier, Ian wrote:
directories with embedded spaces.
find . -type d | cpio -pdum TARGET_DIRECTORY
--
Jerry Feldman
participants (4)
-
Greg Freemyer
-
Jerry Feldman
-
Marlier, Ian
-
Robert Morrison