Tarring only the files of a directory

六月ゝ 毕业季﹏ 提交于 2020-01-17 02:28:37

问题


If I have a folder with a bunch of images, how can I tar ONLY the images and not the folder structure leading to the images without having to CD into the directory of images?

tar czf images.tgz /path/to/images/*

Now when images.tgz is extracted, the contents that are extracted are /path/to/images/...

How I can only have the images included into the tgz file (and not the three folders that lead to the images)?


回答1:


I know you can use --strip-components when untarring although I'm not sure if this would also work when creating.

Perhaps iterate through a folder structure and then pipe the results via stdout/stdin to tar sequentially? (with cat or similar?) IANA Linux Expert so afraid I can only theorise versus provide hard code at this second, you've got me wondering now though...



来源:https://stackoverflow.com/questions/3710146/tarring-only-the-files-of-a-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!