Normally, to zip a directory, I can do something like this:

zip -r archive.zip directory/

However, if I try to remove the extension from archive.zip like this:

zip -r archive directory/

It implicitly appends the .zip extension to the output. Is there a way to do this without creating a .zip and then renaming it?

I'm using this version of zip on Ubuntu 18.04:

Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
This is Zip 3.0 (July 5th 2008), by Info-ZIP.
  • 3
    I'm just curious, but why do you need it?
    – jnovacho
    Dec 19, 2019 at 10:03
  • 2
    @jnovacho I have a Makefile which builds a Python zipapp (zip file with shebang that the Python interpreter knows how to open and run code from). The executable looks cleaner if I omit a file extension extension as would be done with other Unix executables.
    – Wasabi Fan
    Dec 19, 2019 at 19:27

2 Answers 2


The -A (--adjust-sfx) option causes zip to treat the given archive name as-is:

zip -Ar archive directory/

This works even when archive isn’t created as a self-extracting archive.


You can have it provide the zip output to stdout and then redirect it to a file:

zip -r - -- directory/ > archive

The first dash refers to stdout and the pair of dashes separates the initial arguments from the input list, for clarity.

You must log in to answer this question.

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