How to add files to an existing ZIP Archive on macOS and Linux

Sometimes it’s easy to delete a ZIP file and create a new one – say you’ve forgotten to include a file. Just drag it into the folder to be ZIPped up and start again.

However, the clever little ZIP command line tool has a built-in ability to simply add a file to an existing archive without us having to do any manual grunt work. That can come in handy when we no longer have access to existing unZIPped content.

Here’s how it works:

zip /path/to/archive.zip addfile1 addfile2 addfile2

We can even add entire directories this way too, like so:

zip -r /path/to/archive.zip directory/*

This will recursively add all files (indulging hidden and annoying ones) to our file.

Note that ZIP accomplishes this by temporarily extracting all files before creating a new archive for is (while deleting our original file). So in essence, the tools is doing what we’d do manually, just more conveniently and in the background without bothering us.

Jay is founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or drawing on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

You can leave a comment on my original post.