Tar only the Directory structure

后端 未结 5 1767
不知归路
不知归路 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:09

    go into the folder you want to start at (that's why we use find dot) save tar file somewhere else. I think I got an error leaving it right there. tar with r not c. I think with cf you keep creating new files and you only get the last set of file subdirectories. tar r appends to the tar file. --no-recursion because the find is giving you your whole list of files already so you don't want to recurse.

    find . -type d |xargs tar rf /somewhereelse/whatever-dirsonly.tar --no-recursion

    tar tvf /somewhereelse/whatever-dirsonly.tar |more to check what you got.

提交回复
热议问题