macieira
macieira

Reputation: 359

Tar all folders and files except folders with a specific name

Im trying to tar a folder with subdirectories but i want to exclude all folders with the name "log".

I have search and seen that the tar command have the option of --exclude the problem is that this option required to be specific folder not a dynamic one.

Is there any other way?

so far the command i have is:

tar czf ROOT/backup/servers/20150504.tar.gz ./servers --exclude=".*log.*"

Upvotes: 0

Views: 807

Answers (1)

COLINHY
COLINHY

Reputation: 395

If you want to exclude all folders with the name "log", probably using -X is more convenient. Here is an example:

$ find ./servers -type -d -name *log* > excludefiles
$ tar czf ROOT/backup/servers/20150504.tar.gz -X excludefiles ./servers

Upvotes: 3

Related Questions