How do I extract files without folder structure using tar

后端 未结 5 1454
无人共我
无人共我 2021-01-30 12:11

I have a tar.gz-file with the following structure:

folder1/img.gif
folder2/img2.gif
folder3/img3.gif

I want to extract the image files without

5条回答
  •  悲哀的现实
    2021-01-30 13:15

    Based on @ford's answer. This one will extract it to the my_dirname folder. So that we can properly clear the empty folders without affected currently existing files.

    tar xzf images.tgz --transform='s/.*\///' -C my_dirname
    find my_dirname -type d -empty -delete
    

提交回复
热议问题