473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Creating a .gz for a directory

12
Another newbie question...

I searched the internet couple of hours... I pity myself... for not being able to find a command for making .gz file for a directory.
I found only : gzip -c filename.txt
which creates a gz for a single file.. but I am in need of a command for a directory containing files/directories.

please advise. thx in advance.
Feb 23 '07 #1
7 26495
Motoma
3,237 Expert 2GB
Another newbie question...

I searched the internet couple of hours... I pity myself... for not being able to find a command for making .gz file for a directory.
I found only : gzip -c filename.txt
which creates a gz for a single file.. but I am in need of a command for a directory containing files/directories.

please advise. thx in advance.
Gzip, by design, is used to compress single files. The traditional method for creatinga compressed directory, is by using the TAR utility, with compression enabled:
Expand|Select|Wrap|Line Numbers
  1. # tar -czvf directory.tar.gz directory/
  2.  
Feb 23 '07 #2
trs204
12
my requirement says... somebody going to provide me gz and tar.gz both types containing multiple files...

To uncompress... I found the commands:
1) gunzip file.gz ( not sure how to make a sample to test this)
2) tar zxvf file.tar.gz ( able to test this by creating a tar and compressing it)

but as you mentioned... as per the design only file can be compressed... nto the directory... do you mean that they cant the provide me a .gz file, which contains multiple normal files/directories.

thx in advance.
Feb 24 '07 #3
ghostdog74
511 Expert 256MB
my requirement says... somebody going to provide me gz and tar.gz both types containing multiple files...

To uncompress... I found the commands:
1) gunzip file.gz ( not sure how to make a sample to test this)
2) tar zxvf file.tar.gz ( able to test this by creating a tar and compressing it)

but as you mentioned... as per the design only file can be compressed... nto the directory... do you mean that they cant the provide me a .gz file, which contains multiple normal files/directories.

thx in advance.
theoretically speaking, it can be done without using tar. say you have 2 files, file1 and file2 you need to compress together
Expand|Select|Wrap|Line Numbers
  1. cat file1 file2  | gzip > together.gz # compress 2 files into single
  2. gunzip -c together.gz  # this is same as cat file1 file2
  3.  
but i think tar is still better.
Feb 24 '07 #4
trs204
12
Thanks for the reply.. I was able to create the .gz file by specifying multiple files... but when I decompress it using this....
gunzip filename.gz ==> this gave only one file.

I think... cat does the concatenation of multiple files into a single file...

But my situation... is... I am in need of a command that can zip a directory... that directory contains some directories and some files.... and want to retain the same directory structure when I am decompress it.

Looks like they cannot provide me .gz file, which has multiple files and directories. .... is that my understanding seems right?

Thx in advance.
Feb 25 '07 #5
Motoma
3,237 Expert 2GB
Thanks for the reply.. I was able to create the .gz file by specifying multiple files... but when I decompress it using this....
gunzip filename.gz ==> this gave only one file.

I think... cat does the concatenation of multiple files into a single file...

But my situation... is... I am in need of a command that can zip a directory... that directory contains some directories and some files.... and want to retain the same directory structure when I am decompress it.

Looks like they cannot provide me .gz file, which has multiple files and directories. .... is that my understanding seems right?

Thx in advance.
Not without using another utility such as tar.
Feb 25 '07 #6
trs204
12
Thanks Motoma. And thank you all for making me comfortable on this.
Feb 25 '07 #7
Motoma
3,237 Expert 2GB
Thanks Motoma. And thank you all for making me comfortable on this.
You are welcome. Glad to help.

If you figure out how this should (could) be done, post the result back here for us to see!
Feb 25 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Arvind P Rangan | last post by:
Hi, I have tried creating folders through ASP.Net with Directory.Create(path) But it gives me error mscorlib Access to the path "C:\WINNT\system32" is denied. at...
9
by: Sheldon Cohen | last post by:
Hello, I am using c# and running a site that is on a shared host. The code in question is supposed to create a new directory that is coming out of a text box. It works fine on my computer, but...
2
by: Christoffer Sørensen | last post by:
Hi, I have a created a simple file upload asp.net web page which also creates directories on the fly using the following code: string fullpath = Server.MapPath(".\\..\\..\\" + path);...
3
by: James Coleman | last post by:
Hello, The following error is appearing when attempting to create a directory using the availale system.io methods: System.IO.DirectoryNotFoundException: Could not find a part of the path...
0
by: Dan Nash | last post by:
Hi peeps I'm using the IE controls TreeView to create a "Library" type function for all their Manuals, etc. Basically, the plan is to designate a directory on the server as the Library, and...
0
by: tocka20 | last post by:
Hi All, I was wondering if there is a way to create a folder on a seperate server to the one that the web application is using. I have had a look around for a solution but have been unable to...
1
by: ogo796 | last post by:
hi friend i am having problem with creating directory. i used mkdir it works for only one directory but it dosent wanna create the next directory it only create directory one.
0
rsrinivasan
by: rsrinivasan | last post by:
Hi all, I want to create directory with current timestamp by using ant build file. And im using ant 1.7. This is my ant build code. <target name="createDir"> <mkdir dir="myfolder"/>...
6
by: plomon | last post by:
whenever, i try to open a file for writing using fopen("xyz.txt", "w"), i am able to create the file only in default C:\ drive. i want to create a directory in the process of running the c code and...
2
by: briggs | last post by:
I have a file with below contents. the file is dynamically created with these values.It has two parts separated by _. Basically I need to create a main directory(a,b,c,d) first part and create the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.