archiving (ubuntu tar) hidden directories

H2ONaCl picture H2ONaCl · Jan 1, 2011 · Viewed 28.5k times · Source

tar on a directory mydir will archive hidden files and hidden subdirectories, but tar from within mydir with a * wildcard will not. Is this a longstanding and known inconsistency or bug?

Edit (additional information): tar from within mydir with a wildcard will not "see" nor archive hidden files and hidden subdirectories in the immediate directory. However, in the non-hidden subdirectories of mydir hidden files and hidden subdirectories will be archived.

Answer

Madhur Ahuja picture Madhur Ahuja · Jan 1, 2011

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 .