Tarring only the files of a directory

2019-08-17 02:40发布

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条回答
淡お忘
2楼-- · 2019-08-17 03:11

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

查看更多
登录 后发表回答