how to make tar exclude hidden directories

You can use --exclude=".*"

$ tar -czvf test.tgz test/
test/
test/seen
test/.hidden
$ tar --exclude=".*" -czvf test.tgz test/
test/
test/seen

Be careful if you are taring the current directory, since it will also be excluded by this pattern matching.

$ cd test
$ tar --exclude=".*" -czvf test.tgz ./
$ tar -czvf test.tgz ./
./
./seen
./.hidden

Then you need to use --exclude=".[^/]*" as described elsewhere

$ tar --exclude=".[^/]*" -czvf test.tgz ./
./
./seen

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)