I want to unzip the entire content of a zip file to the root of my server.

However each time i try to do this it creates a folder name for the file.

The zip file is called src.zip

the file is at the root of my site.

i used the following command

unzip src.zip

This unzips it but then create a folder called src and places the content there.

I want all of the content to be in the root of site and not in the folder.


Zip files don't store absolute paths. Below is from the zip spec, APPNOTE.TXT The name of the file, with optional relative path.
   The path stored MUST NOT contain a drive or
   device letter, or a leading slash.  All slashes
   MUST be forward slashes '/' as opposed to
   backwards slashes '\' for compatibility with Amiga
   and UNIX file systems etc.  If input came from standard
   input, there is no file name field.  

To get the zipfile to extract to a specific location, use the -d option. This will extract the contents of the zip to the directory specified.

Like so

unzip -d / src.zip

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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