The zip
command has an --exclude
(or -x
) flag to exclude some files:
zip -r --exclude 'img/' compressed_filename.zip path/foldername
Adjust the paths if necessary.
You can also use the find
command to list all the files to be included and pass them to the zip
command.
find path/foldername -name 'img' -prune -o -exec zip compressed_filename.zip {} +
This will search the path/foldername
for all files (and folders). If it finds img
, it stops processing it (-prune
). All other (-o
) found items will be (together, because of +
at the end) passed to the zip
invocation.
man zip
and search for exclude by pressing/
andn
for searching forward, you will be taking to the right place. – Mostafa Ahangarha Feb 28 '17 at 12:31