bashzip

gzipping files that look like gzip but are not - in bash


I need my file to be in proper .txt.gz format. That is the extension, but I can tell from the size they are not gzipped correctly.

I can't zip my file, [because it is already .txt.gz], but I also can't unzip it to re-zip it again properly? See errors below [in bash]

gunzip file.txt.gz
gzip: file.txt.gz: not in gzip format
gzip file.txt.gz
gzip: file.txt.gz already has .gz suffix -- unchanged

This is the same if I use gzip -d

Any help is appreciated!


Solution

  • Rename the file to file.txt to make it gzippable.

    mv file.txt.gz file.txt
    gzip file.txt
    

    Just make sure you don't overwrite an already existing file.