Fast Concatenation of Multiple GZip Files

后端 未结 4 1877
野的像风
野的像风 2020-11-29 19:11

I have list of gzip files:

file1.gz
file2.gz
file3.gz

Is there a way to concatenate or gzipping these files into one gzip file with

4条回答
  •  不知归路
    2020-11-29 19:45

    Here is what man 1 gzip says about your requirement.

    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
    

    Needless to say, file1 can be replaced by file1.gz.

    You must notice this:

    gunzip will extract all members at once

    So to get all members individually, you will have to use something additional or write, if you wish to do so.

    However, this is also addressed in man page.

    If you wish to create a single archive file with multiple members so that members can later be extracted independently, use an archiver such as tar or zip. GNU tar supports the -z option to invoke gzip transparently. gzip is designed as a complement to tar, not as a replacement.

提交回复
热议问题