Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How does one extract a specific folder from a zipped archive to a given directory?

I tried using

unzip "/path/to/archive.zip" "in/archive/folder/" -d "/path/to/unzip/to"

but that only creates the folder on the path I want it to unzip to and does nothing else.

share|improve this question
up vote 12 down vote accepted
unzip <target-zip-file> '<folder-to-extract/*>' -d <destination-path> 

works fine on EL 6

share|improve this answer
what is this EL 6? – Zelda Feb 14 '14 at 18:11
Enterprise Linux 6 (RHEL6) - Red Hat. – slm Feb 14 '14 at 18:15
This works too; its basically the same answer as Mark Adler's, but in a slightly different way. – Enkouyami Feb 19 '14 at 19:44
@Enkouyami Minus differences in quoting, it looks like exactly the same thing. – Camilo Martin Jan 25 '15 at 6:53
@Enkouyami Because backslash in double quotes escapes a character (supposedly the asterisk is being escaped, but I guess it's a typo), while in single quotes the backslash is not interpreted. If one wants a literal backslash, "\\" would be used (else you'd always have to remember which characters are special escapes). So it's a quoting difference if the author meant "quoting the glob character" (unnecessary). Either way a single backslash like that is a typo. – Camilo Martin Mar 3 '15 at 17:05


unzip /path/to/archive.zip 'in/archive/folder/*' -d /path/to/unzip/to
share|improve this answer
did this? I get caution: filename not matched: foldername/\* when I run unzip $repozip "$2-master/\*" -d /srv/www/magento/ where $2 is the folder name in the zip I want to pull all the files and folders out of – jeremy.bass Oct 18 '13 at 2:43
I just tried this and it didn't work for me either! – slm Nov 7 '13 at 20:57
Worked without \, just "path/*". – Alex Oct 28 '14 at 21:24
Is there a way to extract contents of "in/archive/folder/*" that does not preserve path "in/archive/folder/"? I end up using mv afterwards to get files where I needed them. – jerrygarciuh Nov 12 '14 at 20:29
Use -j for that. – Mark Adler Nov 12 '14 at 20:55

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.