The default behavior of gunzip is to delete the .gz file after it decompresses.

There's a way to restore the original file from the decompressed version on Mac OS?


Not the original file, no.

The only way to recover the original file is to "undelete" the original file, using some form of data recovery.

HOWEVER, you can simply re-compress the output files, if all you need is another gzip of them.


copy the .gz file first? It technically doesn't "restore" a file which is what you asked, but I suspect the outcome is what you care about, rather than the process.

cp original.gz tmp.gz && gunzip tmp.gz && mv tmp original

..which you could also add as a bash function in your .bashrc or a local script and pass the original file name to it if this is something you need a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.