• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to gzip more than one files together

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

How do i gzip more than one file in a single zip file?

if i provide : gzip file1 file2, it created twi gzip files .

Please let me know if you ve any soln for this.


Regards,
deo Swaroop
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
gzip can't create .zip files, only .gz files (or maybe that was just a typo on your part).

The usual approach is to create a TAR archive of files, and then to GZIP the .tar file. The Apache Commons Compress library has tar stream implementations, and its web site has example code.
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a reason that the general practice is to first "tar" all the small files into a "tar" file and then use gzip (or bzip2) to compress the tar file. Both of these programs use the basic technique of looking at the input and finding common strings. With all of the small files bundled into the tar file, there are more chances to identify common strings. With the windows-style 'zip' approach, each file is compressed independently, so common strings between files are not used to improve the compression ratio.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The simplest way to make an archive of more than one file is as follows:

1) Create a temporary folder
2) Copy the files into that folder
3) Make that folder your current directory (i.e. cd temp)
3) Use the command: tar cvzf archivename.tar.gz ./*

This will create a zipped and tared archive called archivename.tar.gz of every file in the current directory and in subdirectories under it.

The file can be extracted into the current directory with: tar zxvf archivename.tar.gz

Hope this helps.

Russ.
reply
    Bookmark Topic Watch Topic
  • New Topic