I have a folder in Home directory with the following structure:
top-tree +-- .git +-- branch1 | +-- branch11 | +-- .idea | +-- branch111 | +-- branch112 | +-- branch113 | +-- branch114 | +-- branch1141 | +-- branch1142 | +-- branch1143 | +-- branch115 | +-- branch116 | +-- branch117
Now, I want to tar the entire contents but must exclude all the hidden directories like
.idea and one particular directory
branch114 which has at least 2 subdirectories (the number of subdirectories may vary from time to time).
I tried to do this by using the tar command with the following parameters:
tar -czvf archive.tar.gz --exclude=~/top-tree/branch1/branch11/branch114 --exclude=~/top-tree/.git --exclude=~/top-tree/branch1/branch11/.idea top-tree/ tar -czvf archive.tar.gz --exclude=~/top-tree/branch1/branch11/branch114 --exclude=~/top-tree/.*
But none of the above seems to work. Every single time, the entire contents of the folder
top-tree is placed in archive.tar.gz. I've tried out a lot of things (so many that I can't quote here including this one) suggested in this website and others, played with the permutations of parameters etc. But unlike other similar questions, mine seems like it's a problem with the path. The tar version I'm using is 1.29. Why doesn't this work?