How do I extract files without folder structure using tar

后端 未结 5 1442
无人共我
无人共我 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:12

    Find img*.gif in any sub folder of mytar.tar.gz and extract to ./

    tar -zxf mytar.tar.gz --absolute-names --no-anchored img*.gif --transform='s:.*/::'

    Find img*.gif in any of the 3 folders listed in this specific question in mytar.tar.gz and extract to ./

    tar -zxf mytar.tar.gz --absolute-names --no-anchored img*.gif --transform='s:^folder[1-3]/::'

提交回复
热议问题