3

For example I have files:

./otherfile1
./otherfile2
./excludethisfile
./folder1/otherfile
./folder1/excludethisfile
./folder2/otherfile
./folder2/excludethisfile

I want to zip all files recursively but always exclude the file called 'excludethisfile'

====

To answer whether the post "How do I zip up a folder but exclude the .git subfolder" answers the question:

NO that post is referring to a very simple case of excluding a single subfolder from the zip.

My case is about excluding files of a certain name that might appear in any subfolder, in multiple places, and I want to exclude every one of those files, wherever they appear.

Also this is NOT the case of excluding files of a certain extension ( e.g. .o ), but rather by name ( e.g. filename ).

gb-1957
  • 31

1 Answers1

2

It should work to use the --exclude option, first a 'dry run' showing what to zip,

zip -sf -r file.zip .  --exclude \*/excludethisfile

then, when things look good, do it with

zip -r file.zip .  --exclude \*/excludethisfile

In this case the wild card * will represent the directory path to the files to be excluded.

sudodus
  • 47,684