Search code examples
linuxbashgzipibm-midrange

how to uncompress a binary file which is application/gzip and enconding binary - linux


I've got some files which are supposed to be compressed and binary. I am trying to uncompress them, but I am not able to find the way to do it

What I can see is that the file is compressed and binary, but I have no idea how can I uncompressed to get the file with extension .bin ( those files are coming from an IBM AS/400 system )

$ file RPLMREP.20200831045319063541
RPLMREP.20200831045319063541: gzip compressed data, has comment, comment, last modified: Tue Sep  1 04:53:19 2020
$ file --mime-encoding  RPLMREP.20200831045319063541
RPLMREP.20200831045319063541: binary
$ file --mime-type RPLMREP.20200831045319063541
RPLMREP.20200831045319063541: application/x-gzip
$ gzip -d RPLMREP.20200831045319063541
gzip: RPLMREP.20200831045319063541: unknown suffix -- ignored

Solution

  • The "unknown suffix" error from gzip is a clue that it doesn't want to decompress the file because it doesn't have a .gz suffix. Either rename it...

    mv RPLMREP.20200831045319063541 RPLMREP.20200831045319063541.bin.gz
    gunzip RPLMREP.20200831045319063541.bin.gz
    

    ...or use redirection:

    gzip -d < RPLMREP.20200831045319063541 > RPLMREP.20200831045319063541.bin
    

    (or use the -S option to tell it to recognise your existing suffix, but since that's a datestamp, that doesn't feel right)