开发者

Tarring only the files of a directory

开发者 https://www.devze.com 2023-01-16 06:55 出处:网络
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?

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?

t开发者_如何学Pythonar 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)?


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消