Why does tar --exclude=".*" create an empty archive?
Your pattern excludes ".", which is the directory you're trying to archive. Use ".?*" as the pattern instead.
You appear to be using GNU tar
. Pattern matching in GNU tar
works on the entire path, and does not stop at /
characters. Since you are using ./
for your file list, that means every single file will match ./*
which also matches .?*
. I'd try something like --exclude='.[^/]*'
perhaps.
.*
will always match any file that would be included, as you are using files from .
(which even by itself matches .*
).
You do not need to do anything to exclude the files that you mention, they won't be matched by the glob anyway. The *
glob does not match dot-prefixed files unless you manually enable such functionality (through dotglob
, or your shell's equivalent).