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!

Aulis Ronkainen
  • 2,612
  • 42
  • 29
  • 27
veerman
  • 81
  • 1
  • 3

1 Answers1

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.

Greg Hewgill
  • 5,499
  • 2
  • 29
  • 30
  • 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. – Chris Stratton Jun 04 '11 at 00:13