Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

2 Answers 2

up vote 5 down vote accepted

Try:

unzip "/path/to/archive.zip" "in/archive/folder/\*" -d "/path/to/unzip/to"
share|improve this answer
    
Thanks It worked great. –  Enkouyami Dec 24 '12 at 7:55
3  
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
    
Then the filename was not matched. Do unzip -l xxx.zip to see what's in xxx.zip. –  Mark Adler Oct 18 '13 at 5:24
1  
I just tried this and it didn't work for me either! –  slm Nov 7 '13 at 20:57
2  
Worked without \, just "path/*". –  Alex Oct 28 at 21:24
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 at 18:11
1  
Enterprise Linux 6 (RHEL6) - Red Hat. –  slm Feb 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 at 19:44

Your Answer

 
discard

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.