473,842 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a .gz for a directory

12 New Member
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 26520
Motoma
3,237 Recognized Expert Specialist
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 New Member
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 Recognized Expert Contributor
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 New Member
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 Recognized Expert Specialist
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 New Member
Thanks Motoma. And thank you all for making me comfortable on this.
Feb 25 '07 #7
Motoma
3,237 Recognized Expert Specialist
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
4634
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 System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path) at System.IO.Directory.CreateDirectory(String path)
9
1664
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 I get the following stack trace: System.IO.DirectoryNotFoundException: Could not find a part of the path "D:\". at System.IO.__Error.WinIOError
2
1724
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); DirectoryInfo dir = new DirectoryInfo(fullpath); if(!dir.Exists) dir.Create(); Now the dir.Create() statement gives me a permission denied. The ASP.NET user has been giving full control to the directory and in IIS Admin the directory has write...
3
2300
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 "D:\". at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path) at System.IO.Directory.CreateDirectory(String path) at TestVBProject.createdirectorytest.Page_Load(Object...
0
1013
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 then any files / folders in the directory appear in the tree. Is there some sample code somewhere to show me how to do this?
0
904
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 find one. Basically, we have two servers, one which contains the website and one which contains the data. We need to create a folder on the data server when the user clicks a button on the website server. I am familiar with using...
1
1154
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
4190
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"/> </target>
6
38184
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 want to create the file in that directory. So, i would like to know: 1.) How to create a directory in c ? (in linux and windows) 2.) How to create a file in the directory which has been created ? (in linux and windows) I tried but i failed....
2
2090
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 sub subdirectory(second part after _) into the respective directory. can you please give few tips to do the same. a_1234 a_1234 b_12 a_1234 c_12 c_12345
0
9870
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9715
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10940
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10670
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10308
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9451
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7854
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
4087
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3141
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.