2

I have a lot of directories in the initial folder and I want to zip everything , but exclude all the node_modules folder of each directory , I tried this:

zip -r all_repos.zip . -x '*node_modules*'

But it doesn't exclude all sub-folders.

Any idea how to do it recursively ?

JAN
  • 145

1 Answers1

2

zip looks at files, so to make it include directories you need to add /\* or '/*' according to these instructions about 'include' in `man zip'

          Examples are for Unix unless otherwise specified.]  So to include dir,
          a directory directly  under  the current directory, use
             zip -r foo . -i dir/\*

      or

             zip -r foo . -i "dir/*"

So let us assume it works to 'exclude' too, and try with

zip -r all_repos.zip . -x '*node_modules*/*'
sudodus
  • 47,684