Search code examples
linuxbashzip

How can I exclude both the .git directories and the node_modules directory when using zip?


I want to zip all contents of the present directory into a zip file. While doing this I want to exclude both the .git directory and the node_modules directory.

These commands will exclude .git dir's, but fail to exclude node_modules:

zip -r output.zip . -x '*.git*' -x 'node_modules'

zip -r output.zip . -x '*.git*' 'node_modules'

Solution

  • Please adjust your command to:

    zip -r output.zip . -x '*.git*' -x '*node_modules*'