0

I know it is possible to exclude a particular folder by a command like this:

tar --exclude='/srv/www/project/node_modules' -zcvf /backup/project.tgz .

My question how to exclude all folders named node_modules within the entire /srv/www?

W.M.
  • 204
  • 1
  • 2
  • 8

1 Answers1

0

Use \( ! -name node_modules \) to omit this directory name from find's output.

The -print0 option prints the full name of the file, followed by a null char. This should be used in case of filenames which contain newline chars.

The tar -null option primes the following -T option to read null-terminated files verbatim.

The tar -T - option reads files from stdin (the output from the pipe).

find . -type d \( ! -name node_modules \) -print0 | tar --null -czf /backup/project.tgz -T -
suspectus
  • 658
  • 1
  • 5
  • 11