1

Recently, I have encountered a zip file (containing a single file) that printed a custom message to standard out when I ran

unzip archive.zip

without further arguments.

I was not aware that this is possible. I did read up about file comments in the ZIP specification, but they seem to behave differently on the CLI.

When I used zip -c and entered a custom message, I could see that my custom message somehow gets compressed into the archive, but it won't print automatically when unzipping the file again.

Using unzip -l lets me view my message—but that is not how the original file archive.zip behaved. unzip -l archive.zip first prints the custom message, and then lists the archive contents. In opposite to my experiments with file comments, the comment is not printed in the list.

Therefore my question: how can I create a ZIP file that prints a custom message upon extraction? (And also, what is this feature called, if not file comments?)

1 Answer 1

2

I think you are looking for --archive-comment. Quote from manpage:

       -z
       --archive-comment
              Prompt  for a multi-line comment for the entire zip archive.  The comment is ended by a line containing just a period, or an end of file condition (^D on Unix, ^Z on MSDOS, OS/2, and
              VMS).  The comment can be taken from a file:

                     zip -z foo < foowhat

zip --archive-comment -c -r test test prompts user to enter a special comment for the entire archive.

During extraction (Message is Hello):

unzip ../test.zip
Archive:  ../test.zip
Hello.
   creating: test/
 extracting: test/test.txt

You must log in to answer this question.

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