Today I wanted to create a tar file that excludes hidden files and folders — ones that start with a dot (i.e. ‘.’).
Like a good boy, I read the fine man page (RTFM — sometimes the F is replaced with a ruder word than “fine”) but I couldn’t get it to work after several different variations of the exclude pattern. It seems that the exclude pattern that tar expects doesn’t follow any of the regular expression (a.k.a. regex) syntaxes that I’m familiar with. Someone enlighten me here if you know what it expects.
Anyway, after lots of unsuccessful googling, I finally found a relevant post. Here’s an example of the magical incantation to do this trick (it seems to work in my brief testing using Ubuntu Linux):
tar -cf test.tar foo/ --exclude '.*'
If this tip helped you, please leave me a comment or send me an email!


