On Thu, Aug 16, 2018 at 10:40:14AM -0400, cyaiplexys wrote: > tar -czf archive.tgz /home/me/dirToARchive/. > --exclude=/home/me/dirToARchive/.mysetuptemp > --exclude=/home/me/dirToARchive/.myotherdotfile > --exclude=/home/me/dirToARchive/.anotherdotfile > > I found it doesn't matter if I put the --excludes before the -czf or after > everything, I still end up with EVERY dot file in the directory instead of > ONLY the ones that are NOT on the list.
wooledg:/tmp/x$ touch .good .bad1 .bad2 wooledg:/tmp/x$ tar czf ../foo.tgz --exclude ./.bad1 --exclude ./.bad2 . wooledg:/tmp/x$ tar tzvf ../foo.tgz drwxr-xr-x wooledg/voice 0 2018-08-16 10:43 ./ -rw-r--r-- wooledg/voice 0 2018-08-16 10:43 ./.good I think your primary problem is that you are passing absolute paths to tar. This is evil. You wouldn't want absolute paths in your tarball, and in fact, GNU tar will chastise you for doing so, and then will strip the leading slashes for you. (Unix tar is not so forgiving. It will gleefully do exactly what you said, creating a tarball with absolute paths in it, which means it cannot safely be extracted.) Perhaps there is some kind of collision between the auto-stripping of the leading slashes, and your --exclude patterns which still have those leading slashes on them.