Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The extracted tgz contains a structure approximately like:

  • Source
    • header.h
    • bozo.h
    • dir2
      • anotherheader.h

The following:

tar xzf libm.tar.gz --strip-components=2 Libm-2026/Source/*.h/

extracts header.h, bozo.h and anotherheader.h. What would make it only extract the ones at the specified directory specifically – that is, only header.h and bozo.h?

share|improve this question

1 Answer 1

With GNU tar:

tar -xvzf libm-2026.tar.gz --wildcards 'Libm-2026/Source/[!dir2]*.h'

Output and extracted files:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.