Tar only the Directory structure

后端 未结 5 1756
不知归路
不知归路 2021-02-13 13:26

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.

5条回答
  •  南方客
    南方客 (楼主)
    2021-02-13 14:03

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

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

    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 -
    

提交回复
热议问题