Differences between revisions 1 and 2
Revision 1 as of 2007-05-02 22:54:40
Size: 558
Editor: redondos
Comment:
Revision 2 as of 2007-05-07 19:06:55
Size: 570
Editor: GreyCat
Comment: *cough*
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
or with GNU-{{{tar}}}, and less obscure syntax: or with GNU {{{tar}}}, and more verbose syntax:
Line 16: Line 16:
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. 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.

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)