Differences between revisions 3 and 4
Revision 3 as of 2008-05-08 23:25:57
Size: 560
Editor: GreyCat
Comment: reformat
Revision 4 as of 2008-11-22 14:09:45
Size: 560
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
[[Anchor(faq10)]] <<Anchor(faq10)>>

How can I recreate a directory structure, without the files?

With the cpio program:

  •  cd "$srcdir"
     find . -type d -print | cpio -pdumv "$dstdir"

or with GNU tar, and more verbose syntax:

  •  cd "$srcdir"
     find . -type d -print | tar c --files-from - --no-recursion |
       tar x --directory "$dstdir"

This creates a list of directory names with find, non-recursively adds just the directories to an archive, and pipes it to a second tar instance to extract it at the target location.

BashFAQ/010 (last edited 2023-09-22 06:29:48 by StephaneChazelas)