I'm trying to zip a directory a linux using the following command:

zip -r file.zip .

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?

2 Answers 2


The answer you're most likely looking for is:

zip -r file.zip . -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 file.zip $PWD

which will compress the whole folder structure.

  • cat you explain why this works? Jul 14, 2020 at 0:31

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 file.zip .
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 file.zip
  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

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.