8

So I tried to make a gzipped backup of my entire directory structure, but I inadvertently issued the command gzip -r ./, hoping to add all files and folders to a single gzip archive.

This obviously is very wrong, but before I had time to quit, it gzipped each of my files individually (recursively) and deleted the original. Now I have a file structure that is completely made up of gzipped files. Does anyone know the command to undo what I have done (ie. extract the gzip file in place and then delete the gzip file)?

Edit: Credit to Greg, gunzip -r ./' solved it!

5
  • 1
    this is probably close: find -type f -name '*.gz' | xargs gunzip Commented Jun 3, 2011 at 23:02
  • 1
    Did you try gunzip -r ./? Commented Jun 3, 2011 at 23:03
  • 1
    Heh. But make sure to make a backup copy first this time. It's generally harder to undo an undo gone oops than the initial oops.
    – pst
    Commented Jun 3, 2011 at 23:06
  • I moved my comment to an answer, since it solved your problem. Commented Jun 4, 2011 at 0:00
  • In the future, if you want to make a gzipped backup of your entire filesystem, use tar czf backup.tar.gz /.
    – Patches
    Commented Jun 4, 2011 at 1:29

1 Answer 1

12

To undo this, use the opposite command:

gunzip -r ./

Note that the original gzip command will skip over files that already have a .gz suffix, because there's no point in compressing them twice. However, the above gunzip command will decompress such files, because it doesn't know that gzip skipped them.

1
  • 1
    Good point - that might be an argument for using the find idea with -cmin (or -ctime if it's been days ago) as an additional qualifier so as to avoid unzipping what originally were gz files at the time of the accidental command. Commented Jun 4, 2011 at 0:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .