Linux: Excluding directories when using zip

If you are using zip and find yourself needing to exclude a directory (.git, build, etc), the “-x” exclude switch can provide that functionality.  Take the following directory structure:

$ find .
.
./two.txt
./skipme
./skipme/three.txt
./one.txt

You can exclude the entire ‘skipme’ folder and everything in it with:

zip -r myzip.zip * -x skipme/*

And if you need to exclude multiple filters:

zip -r myzip.zip * -x skipme/* -x one.txt

And if you wanted to skip a file and flatten out the directory structure:

zip -rj myzip.zip * -x one.txt

To show the contents of a zip:

zipinfo -1 myzip.zip