how to exclude multiple directories
Hi,
I am trying to exclude multiple directories when using tar. I can do it for just one directory with --exclude=directory I can also do it for multiple directories by typing that code again and again. But.. I now have this: Code:
tar -czpv --exclude="$EXCLUDE" Code:
EXCLUDE=".gnome2 excludingtest' Many thanks! Also.. i tried --exclude-tag --exclude-tag-all --exclude-tag-under but to no avail. Any help would be greatly appreciated! Thanks |
The tar exclude statement is not in the form --exclude=directory, it's in the form --exclude PATTERN. If there was a common naming pattern to the directories you wanted to exclude, (dir01, dir02, etc.), then that's the way you would accomplish that.
You can also use the --exclude-from FILE parameter, where the named file contains a list of files to be excluded. I'm not sure if it could be used to just specify directories instead, but it might be worth a shot. Another method would be to run multiple tar commands for each directory you actually want to back up, and append them all to the file created in the first one. |
Cheers SL00b, but I figured it out using this:
Code:
-X <(for i in ${EXCLUDE}; do echo $i; done) |
All times are GMT -5. The time now is 04:54 AM. |