Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

To obtain a fresh zip file just like as tar does, do I have to perform rm before executing zip?

$ mkdir foo; touch foo/bar
$ zip -r foo
  adding: foo/ (stored 0%)
  adding: foo/bar (stored 0%)
$ rm foo/bar; touch foo/baz
$ zip -r foo
  adding: foo/ (stored 0%)
  adding: foo/baz (stored 0%)
$ unzip -l
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2011-10-27 07:49   foo/
        0  2011-10-27 07:49   foo/bar
        0  2011-10-27 07:49   foo/baz
---------                     -------
        0                     3 files
share|improve this question
up vote 11 down vote accepted

Use the -FS option to "file sync"

zip -FSr foo

This will add any new files in the folder to the zip, and delete any files from the zip that aren't in the folder.

share|improve this answer
Thank you for your answer! – asari Jan 16 '12 at 7:07
Which version of zip has this option? My zip command does not recognise "-S" – Jayan Jun 26 '14 at 11:08
The switch is -FS not -F and -S together. This has been there since zip 3.0 at least. Check man zip. – Paul Jun 26 '14 at 13:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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