Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

If I zip a folder, make changes to the normal unzipped files and then zip that folder again, is it possible to have only those changed files in a new separate archive?

So first zip command would be:

zip -r *

Second one something like:

zip -r -u * < // would save output
share|improve this question
up vote 4 down vote accepted

Yes, it's possible to do this and there's a zip command switch specially designed for that purpose. I'll show you by way of an example, and then you can adapt it to your own purposes.

I first created a zip archive of my script folder with the following command (working from my home folder):

zip -r Scripts

Now this had 76 items. I then added some 2 pdfs to the Scripts folder on disk and then ran the following command, and transferred just the new and changed files to a new zipfile:

zip -r Scripts -DF --out

This was the output:

updating: Scripts/ (stored 0%)
adding: Scripts/GIMP+Magazine+Issue+1.pdf (deflated 2%)
adding: Scripts/Whitepaper-CentralisedLogging-v1.pdf (deflated 10%)

Now only these 2 new files are in, and they have not been added to the original zip. In the command, the -DF option allowed us to create a 'difference archive' specified with the --out switch, so that any new files present in the folder on disk, but not in the original zip, go to the new zip. So according to the man page, it is indeed possible to

create an archive that contains all new and changed files since the original archive was created. For this to work, the input file list and current directory must be the same as during the original zip operation.

There are some interesting options to play around with for zip, so please see man zip or the Ubuntu manpages online.

share|improve this answer

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.