Selectively zip files and folders

From the command line, you can pass the zip command the -xi flag to selectively specify a list of files and folders to put into a single archive.

So, say you have the following files/folders:

random.txt
test.php
index.html
ignore.txt 
+ testdir 
    – subfile.info 

And you want all these in an archive called “blat.zip” except for index.html and ignore.txt, this would be the command:

$ zip -r9 blat.zip -xi random.txt test.php testdir

This creates blat.zip (maximum compression level of 9, r for recursive to go down into subdirectories) with the requested files and folders in it. Very handy!

You can test the result with unzip -l blat.zip (-l = list).