archiving (ubuntu tar) hidden directories
With wildcard it will not work. You have to specify . (current directory) if you mean full directory including hidden files. You can do
tar -cvpzf test.tgz .
The answer is that the *
wildcard is handled by the shell and it just does not expand to things that start with a dot. The other wildcard ?
also does not expand to things that start with a dot. Thanks to Keith for pointing out it is the shell that does the expansion and so it has nothing to do with tar
.
If you use shopt -s dotglob
then expansion will include things like .filename
. Thanks to Andy.
Use shopt -u dotglob
to turn it off.
Switching the dotglob
option does not change ls
itself. Rather it just changes expansion behaviour as exhibited in something like ls *
.
Edit: My recommendations are in a comment below.
You can use:
tar -cvpzf test.tgz * .??*
But, this works only for hidden files with names > 2 (to prevent '.' and '..')