仅tar 目录结构 [英] Tar only the Directory structure

查看:38
本文介绍了仅tar 目录结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想复制我的目录结构,不包括文件.tar 中是否有任何选项可以忽略所有文件并仅递归复制目录.

I want to copy my directory structure excluding the files. Is there any option in the tar to ignore all files and copy only the Directories recursively.

推荐答案

您可以使用 find 来获取目录,然后对它们进行 tar:

You can use find to get the directories and then tar them:

find .. -type d -print0 | xargs -0 tar cf dirstructure.tar --no-recursion

如果您有大约 10000 个以上的目录,请使用以下方法来解决 xargs 限制:

If you have more than about 10000 directories use the following to work around xargs limits:

find . -type d -print0 | tar cf dirstructure.tar --no-recursion --null --files-from -

这篇关于仅tar 目录结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆