Search code examples
shellziptar

Zip - How do you exclude files from a zip using a database black-list?


I know that tar has the option to exclude files to be included in a new archive using a black list database (e.g. exclude.db).

tar -czf --exclude-from="exclude.db" archive.tar.gz /home/user/directory/

Where the exclude.db file looks like this:

exclude1.txt
exclude2.jpg
exclude3.db

How would you do this when using zip?

Zip has the option of excluding files, but as far as I see, you can't do this using a list in a file.


Solution

  • With Zip 3.0 and Ubuntu:

    zip -r -x@exclude.db archive.zip /home/user/directory/
    

    Example exclude.db, if the files are located in subdirectories:

    */exclude1.txt
    */exclude2.jpg
    */exclude3.db