LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to zip a dir (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-zip-a-dir-764751/)

shravee 10-27-2009 05:49 AM

how to zip a dir
 
i need to zip a dir, which contains files and other dir.

i am able to zip the folder along with the files but not the directories present in it.

how should i zip a dir along with the contained dir and files.


regards
shravee

repo 10-27-2009 05:56 AM

You can use tar
Code:

tar cvzf foo.tgz directory
will tar the directory (and its files/subdirectories) into a tar file named foo.tgz.

Nylex 10-27-2009 06:12 AM

If you actually want to produce a zip file, why don't you read the man page for "zip"?

linuxlover.chaitanya 10-27-2009 06:20 AM

Use -r to descend into directory recursively.

eg: zip -r foo foo

i92guboj 10-27-2009 06:26 AM

Please, check the man page for zip, tar, 7z or whatever tool you want to use to compress the files. Then, if you still have some concrete doubt, come back.

soumyacs 10-27-2009 08:04 AM

Consier abc is a directory

To zip that directory , execute -

zip abc.zip abc

To unzip it -

unzip abc.zip

linuxlover.chaitanya 10-28-2009 12:17 AM

@soumyacs: The OP has a specific issue where folders inside parent folder are left as it is and not included in the zip archive. -r option is needed for recursive descent into folders.

shravee 10-28-2009 03:37 AM

hi repo,
cant i get the compressed folder in .zip format which solves my problem of compressing subdirectories also.

rhadmn 10-28-2009 06:04 AM

Hi Shravee,

You can try with the below command.

# zip -r <dirname>.zip <dirname> -- which will zip the entire dir/files contained in the parent directory recursively.

for eg :

$ zip -r orange.zip orange
adding: orange/ (stored 0%)
adding: orange/potato (stored 0%)
adding: orange/test/ (stored 0%)
adding: orange/test/ptsadminlog (deflated 88%)
$

$ du -sh orange*
272K orange
32K orange.zip
$

Works for me.

Note : Please try and let me know incase if you still face any issues.

Regards,
RHADMN

shravee 10-28-2009 11:17 PM

thanks
 
thanks rhadmn,

its working for me......... too.

regards
shravee


All times are GMT -5. The time now is 07:29 AM.