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
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]/::'