I am trying to tar everything within my home folder into a tar and I want to exclude certain folders like hidden ones and test_tree (which is actually nested quite a bit inside of other folders).

I tried executing this command:

tar -vcf everything.tar . --exclude='.*' --exclude='test_tree'

inside of the home directory cd ~ but the tar created was completely empty. What is going on?

4 Answers 4


I have the same issues, --exclude='.*' works fine on MacOS but not on Linux. You can do,

tar -vcf everything.tar . --exclude='./.*' --exclude='test_tree'


tar -vcf everything.tar . --exclude='.[^/]*' --exclude='test_tree'


It is the use of . as your source coupled with telling tar to exclude things starting with . that is the problem. Try using the absolute path for example /home/user or "$PWD" if you are in the directory already and it should work fine.


Best solution is to cobble up a file with the offending names, and go:

tar cf my-precious.tar -X file-of-offenders .

(Dunno if -X is a GNUism, though... but you seem to be using GNU tar anyway).


To match "hidden files" using a shell-style pattern, use .[^.]*.

Using .* matches the special directory entry . (and also ..). This is usually not what you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .