Python-list Digest, Vol 75, Issue 226

r0g aioe.org at technicalbloke.com
Tue Dec 22 14:30:58 EST 2009


Gabriel Genellina wrote:
> En Mon, 21 Dec 2009 16:30:13 -0300, Pulkit Agrawal
> <thatguypulkit at gmail.com> escribió:
> 
>> I am writing a script wherein I need to merge files into existing tar.gz
>> files. Currently, I am using tarfile module. I extract the tar.gz to a
>> tempdir and copy the new file there and re-compress all the files back
>> into
>> a tar.gz.  Is there a better way to do it?
> 
> Since noone answered yet: no, I don't think you can avoid to decompress
> and recompress those files.
> 



Erm, I always thought it was OK to simply cat gzipped files together...


>From man gzip...


       Multiple  compressed  files  can  be concatenated. In this case,
gunzip will extract all members at once. For example:

             gzip -c file1  > foo.gz
             gzip -c file2 >> foo.gz

       Then

             gunzip -c foo

       is equivalent to

             cat file1 file2



Roger.



More information about the Python-list mailing list