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

I have a file myarchive.zip that contains many directories, files, etc. Let's say this myarchive.zip file lives in a directory called "b". Well, when I use the "unzip myarchive.zip" command, the system creates a directory by default called "myarchive" with the contents of the zip file. I do not want the system to create this "myarchive" directory - I just want the contents to be extracted to directory "b". Is this possible?

What I've been doing now is simply issuing a "cp" command to copy the files from the newly created directory (in this case "myarchive" to "b") to where I want them.

share|improve this question
By default, unzip doesn't create a directory. Your zip file probably has the directory at its top level. – Chris Down Apr 18 '13 at 3:29
You could use mv instead of cp. mv archive/* .; rmdir archive/ or similar. – frostschutz Apr 18 '13 at 3:35

My version of unzip has a -j option to not create any directory.


unzip -j /path/to/file.zip

Will extract all the files into the current directory without restoring the directory structure stored in the zip file.

If you want to only remove one level of directories from the archive, (extract myarchive/dir/file as dir/file, not file), you could use bsdtar (which does supports zip files in addition to tar files) instead and its -s option.

bsdtar -xf /path/to/file.zip -s'|[^/]*/||'
share|improve this answer
When using -j the archive directory structure is not recreated and all files are deposited in the extraction folder. This means ALL subfolders are dropped. So if you would have zip/A/f1, zip/A/B/f2 and zip/A/B/C/f3 you would end up with a single folder with f1, f2, f3. It gets funky if you have files with the same name in different subfolders. Usually you want to just drop the top folder not the entire directory structure. – Cristian Vrabie Feb 4 at 16:01
@CristianVrabie, well that's exactly what I'm saying in the answer. I've added a bsdtar alternative for what you're asking. See edit. – Stéphane Chazelas Feb 4 at 16:38
WORST ANSWER EVER! – Ozan Kurt May 16 at 0:57

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.