Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Perl Way To Gzipping/Joining Multiple Gzip Files

by neversaint (Deacon)
on Nov 04, 2011 at 06:21 UTC ( #935839=perlquestion: print w/replies, xml ) Need Help??

neversaint has asked for the wisdom of the Perl Monks concerning the following question:

Dear Masters,
I have list of gzip files:
file1.gz file2.gz file3.gz
Is there Perl ways to join or compressing these files into one gzip file (one batch file) without having to decompress them individually? Moreover we want to preserve the files in gzip format after unzipping the batch file.

In practice we will use this in a web database (CGI). Where the web will receive a query from user and list out all the files based on the query and present them in a batch file back to the user.

I understand that we can do:
cat file1.gz file2.gz file3.gz > allfiles.gz
However upon gunzipping allfiles.gz the files  file1.gz file2.gz file3.gz were not preserved in their existing gzip format.

---
neversaint and everlastingly indebted.......

Replies are listed 'Best First'.
Re: Perl Way To Gzipping/Joining Multiple Gzip Files
by anneli (Pilgrim) on Nov 04, 2011 at 07:44 UTC

    Is there Perl ways

    Not really, as this is just a question of compression and archival. gzip doesn't do file-separation; it's just stream compression. So if you cat the existing .gz files together, as you see, you get one file back.

    tar is made exclusively for putting multiple files together; have you considered taring the .gzs together? (You'd have .gz.tar instead of .tar.gz, kinda!)

    Or, try .zip or .rar with a zero compression setting (as you will probably incur a size gain trying to compress the already compressed .gzs).

Re: Perl Way To Gzipping/Joining Multiple Gzip Files
by Anonymous Monk on Nov 04, 2011 at 06:43 UTC

    gzip works the way it works, independent of perl, so this is not a perl question :)

    try stuffing the gzipped files into a zip file

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://935839]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2020-02-18 00:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (74 votes). Check out past polls.

    Notices?