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?

1 Answer 1

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 -

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.