In Linux I can zip all(except hidden files) in current directory by doing:

zip 1.zip *

But how do I include the hidden files?

share|improve this question
up vote 90 down vote accepted

EDIT: The correct way is zip -r 1.zip .

The commands shown below are incorrect because they also include the parent directory.


Have you tried this:

zip yourfile.zip sourcedir/* .*

or you in your case

zip 1.zip * .*

It should include all hidded files also.

share|improve this answer
1  
that pretty much works but now im also getting ../ which i dont think i want. – Hermann Ingjaldsson Sep 19 '12 at 10:54
    
by ../ you mean, you are also compressing files from the directory above? – Gunnar Sep 19 '12 at 11:00
    
apparently. When i do zip 1.zip * .* (in a folder with subfolder a and a hidden file called '.hidden_file') i get: – Hermann Ingjaldsson Sep 19 '12 at 11:03
11  
ok i got it its: 'zip 1.zip * .[^.]*'. Thanks for the help. – Hermann Ingjaldsson Sep 19 '12 at 11:09
9  
or as you said, 'zip -r 1.zip .', which also works and is simpler. – Hermann Ingjaldsson Sep 19 '12 at 11:12

Or you can add more simple

zip 1.zip ./
share|improve this answer

Just to be sure it is not forgotten since this is a forum for developers and a good number of us use git.

An easy way to get only what you want in the zip is to use git archive -o filename.zip branch

share|improve this answer
1  
Thank you! That was exactly what I needed: a lot less troubles than manually calling zip. – Egon Apr 4 '16 at 20:33

If you want to zip all files (+hidden files) Kindly using: zip -r namefiles.zip . The "." is all files in folder.

share|improve this answer
    
How is your answer different to the accepted answer, which states "The correct way is zip -r 1.zip ."? – Simon MᶜKenzie Jan 14 '16 at 2:34
    
@SimonMᶜKenzie He also explained what "." means. That made the difference I suppose. – Chung Lun Yuen Oct 15 '16 at 7:18
1  
The "." is NOT all files in folder. It means the "current folder" itself, which would ultimately include all its contents. – Izhar Aazmi Aug 11 '17 at 7:33

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.