LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-27-2009, 06:49 AM   #1
shravee
Member
 
Registered: Sep 2009
Posts: 76

Rep: Reputation: 15
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
 
Old 10-27-2009, 06:56 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,528

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
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.
 
Old 10-27-2009, 07:12 AM   #3
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
If you actually want to produce a zip file, why don't you read the man page for "zip"?
 
Old 10-27-2009, 07:20 AM   #4
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
Use -r to descend into directory recursively.

eg: zip -r foo foo
 
Old 10-27-2009, 07:26 AM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 386Reputation: 386Reputation: 386Reputation: 386
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.
 
Old 10-27-2009, 09:04 AM   #6
soumyacs
LQ Newbie
 
Registered: Oct 2009
Posts: 21

Rep: Reputation: 0
Consier abc is a directory

To zip that directory , execute -

zip abc.zip abc

To unzip it -

unzip abc.zip
 
Old 10-28-2009, 01:17 AM   #7
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
@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.
 
Old 10-28-2009, 04:37 AM   #8
shravee
Member
 
Registered: Sep 2009
Posts: 76

Original Poster
Rep: Reputation: 15
hi repo,
cant i get the compressed folder in .zip format which solves my problem of compressing subdirectories also.
 
Old 10-28-2009, 07:04 AM   #9
rhadmn
Member
 
Registered: Oct 2009
Location: Bangalore
Distribution: Redhat Linux, Solaris, CentOS
Posts: 34

Rep: Reputation: 1
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

Last edited by rhadmn; 10-28-2009 at 07:05 AM.
 
Old 10-29-2009, 12:17 AM   #10
shravee
Member
 
Registered: Sep 2009
Posts: 76

Original Poster
Rep: Reputation: 15
Thumbs up thanks

thanks rhadmn,

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

regards
shravee
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Root Dir Change and New Dir Added issue in CentOS 5 Ginnyz Linux - Server 2 06-01-2009 09:29 PM
Command to display /dir, /dir/sub, /dir/sub/files knockout_artist Linux - Newbie 9 10-25-2007 03:57 PM
how to unzip a zip file on a selected dir in linux ? sunlinux Linux - Software 1 06-12-2006 05:52 AM
create a self-extracting zip file with zip on solaris? samsolaris Solaris / OpenSolaris 3 10-15-2004 02:50 AM
zip files turns to dir´s?! Sofia Linux - General 0 02-20-2002 03:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration