Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Can I tar a directory structure? Is it posssible to tar a directory structure. I dont need the data inside the directories. These are NFS and Samba shares and just want to be able to recreate the mount points with min fuss. Thanks
The difference being this person doesn't want files in the directories. So, tarring up the directory would work, but isn't what they are looking for. They want structure, not files
Well I don't think there is any specific switch for tar which will do this, at least I couldn't find any. Here is how I would do something like what you where looking for. It's just an example of the commands I used, you might want to make a script out of it if you want to do it more often.
Code:
$ mkdir /tmp/dirstruct
$ cd /tmp/dirstruct
$ find /usr/include -type d | sed -e 's#/usr/include/##' | xargs mkdir
$ tar czvf dirstruct.tar.gz *
$ mkdir /tmp/newdirstruct
$ cd /tmp/newdirstruct
$ tar xzvf ../dirstruct/dirstruct.tar.gz
The find command searches for only directories. The sed command then strips off the leading path. You have to make sure that in the sed command the trailing / is present otherwise it will try to make the directory structure in the root which isn't what you want. The xargs command passes the directories to the mkdir command so it can create each directory in the current directory.
Well hope that helps get you closer to the solution to your problem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.