Google Answers: Exclude directory in tar and zip A note to remember with tar
Lets say we have a directory structure as such
T1
T1/T2
T1/T2/Readme.file.should.appear
T1/T2e
T1/T2e/Readme.file.should.not.appear
T1/T3
T1/T3/Readme.file.should.appear
T1/T3e
T1/T3e/Readme.file.should.not.appear
Where all are above are folders, except lines with "Readme.file" in them
- tar cvfz T1.tgz T1 -- will include everything in T1.tgz
- tar cvfz T1.tgz --exclude T1/T2e --exclude T1/Te3 -- will exclude T1/T2e folder and T1/T3e folder and their contents in T1.tgz
- tar cvfz T1.tgz --exclude T1/T2e/ --exclude T1/Te3/ -- will include T1/T2e folder and T1/T3e folder, but exclude their contents (i.e. Readme.file.should.not.appear will not appear, but it's parent directory will appear) in T1.tgz