Skip to content

Instantly share code, notes, and snippets.

@moreati
Created September 5, 2025 11:07
Show Gist options
  • Select an option

  • Save moreati/939f33e30679d4443eebf1da3c950f76 to your computer and use it in GitHub Desktop.

Select an option

Save moreati/939f33e30679d4443eebf1da3c950f76 to your computer and use it in GitHub Desktop.
Multiple members are allowed in a gzip file

A gzip (.gz) file typically contains a single member, but as per RFC 1952 it can contain many members.

2.2. File format

A gzip file consists of a series of "members" (compressed data sets)

GNU gzip and Apple gzip both appear to decompress multiple members to a single output file.

Demo

  1. Create some test files

    $ echo foo > foo.txt
    $ echo bar > bar.txt
  2. Individually gzip them (which deletes the originals)

    $ gzip foo.txt
    $ gzip bar.txt
  3. Concatenate the invidiual gzip files into a combined gzip

    $ cat foo.txt.gz bar.txt.gz > foobar.gz
  4. Delete the indiduals, leaving only the combined gzip

    $ rm foo.txt.gz bar.txt.gz
    $ ls -l 
    total 1
    -rw-r--r-- 1 alex alex 64 Sep  5 10:48 foobar.gz
  5. gunzip the combined, contents of both original files are written to a single uncompressed output file

    $ gunzip foobar.gz
    $ ls -l
    total 1
    -rw-r--r-- 1 alex alex 8 Sep  5 10:48 foobar
    $ cat foobar
    foo
    bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment