user580950 user580950 - 4 months ago 13
Bash Question

Exclude .Gz File while zipping - Debian Linux

zip -r foo.zip foo/


I am using the above Linux command in
putty
which compresses the folder ‘foo’ and all of its contents into a zip file called ‘foo.zip’.

The command works great, I would like to exclude all files in all the subdirectories that have
.gz
file extension.

Is there a command to do it

pah pah
Answer

Use the --exclude (-x) option:

zip -r foo.zip foo -x \*.gz