Super User is a question and answer site for computer enthusiasts and power users. 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'm trying to zip a directory a linux using the following command:

zip -r .

This works, but it isn't include the empty directories that I want to be included in the zip file. How can I get them to be included?

share|improve this question
up vote 3 down vote accepted

The answer you're most likely looking for is:

zip -r . -i \*

You get a warning when zipping an empty folder but again the solution is size-agnostic for its function. It works for empty and non-empty directories.

This solution works in the relative sense unlike solutions that use $PWD such as

zip -r $PWD

which will compress the whole folder structure.

share|improve this answer

What version of zip are you using? I've got:

$ zip -v
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
This is Zip 3.0 (July 5th 2008), by Info-ZIP.

And if I create some directories:

$ mkdir -p a/{b1,b2}

And then create a zip file:

$ zip -r .
adding: a/ (stored 0%)
adding: a/b1/ (stored 0%)
adding: a/b2/ (stored 0%)

The resulting archive appears to have the empty directories:

$ unzip -l
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  01-11-2011 11:54   a/
        0  01-11-2011 11:55   a/b1/
        0  01-11-2011 11:54   a/b2/
---------                     -------
        0                     3 files
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .