Fast Concatenation of Multiple GZip Files

后端 未结 4 1876
野的像风
野的像风 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 20:03

    Just use cat. It is very fast (0.2 seconds for 500 MB for me)

    cat *gz > final
    mv final final.gz
    

    You can then read the output with zcat to make sure it's pretty:

    zcat final.gz
    

    I tried the other answer of 'gz -c' but I ended up with garbage when using already gzipped files as input (I guess it double compressed them).

    PV:

    Better yet, if you have it, 'pv' instead of cat:

    pv *gz > final
    mv final final.gz
    

    This gives you a progress bar as it works, but does the same thing as cat.

提交回复
热议问题