How to restore the original file.gz after running a gunzip -f file.gz?

0

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?

SuperAtic

Posted 2019-04-30T15:58:34.560

Reputation: 101

Answers

0

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.

music2myear

Posted 2019-04-30T15:58:34.560

Reputation: 34 957

0

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.

darrend

Posted 2019-04-30T15:58:34.560

Reputation: 103