Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to create a tarball of a given directory. However, I need to make sure hidden files are included too (such as those beginning with .).

Will the following command automatically take the hidden files into account?

tar -cvzf packed.tar.gz mydir

If not, how can I make sure I include hidden files?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Yes, it will.

Files starting with . are not "hidden" in all contexts. They aren't expanded by *, and ls doesn't list them by default, but tar doesn't care about the leading .. (find doesn't care either.)

(Of course, this is one of those things that's easy to find out by experiment.)

share|improve this answer
    
Thanks. Yes experiment is sometimes a solution to find an answer, but in this case, I am not a unix expert and I know behaviors - in general - can be modified with configuration. What if two systems are not configured the same way? The belief I might build from one system might not be true for another. –  JVerstry Feb 17 '12 at 17:55
    
@JVerstry: Good point. A suggestion, though; a question like "I tried this, and it worked; is it guaranteed?" would have been even better. –  Keith Thompson Feb 17 '12 at 18:20
    
tar --help lists several different options, all beginning with --exclude that allow one to exclude various files based on name, pattern, etc. Agreed, experimentation is a great way to test and verify if something works as expected. Make backups regularly! –  bdowning Feb 17 '12 at 20:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.