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 folder.zip *
Second one something like:
zip -r -u folder.zip * < changedFilesOnly.zip // would save output
Best Answer
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):
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:
This was the output:
Now only these 2 new files are in
new.zip
, 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 toThere are some interesting options to play around with for zip, so please see
man zip
or the Ubuntu manpages online.