5

So.. yeah. I don't spend a lot of time on the linux command line and instead of making a zip file of the web directory, I gzipped everything in the web directory. What's the anecdote to stupidly doing this from the web root?

sudo gunzip ../_downloads/ecpt ./*

I really need to undo this asap..

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
doub1ejack
  • 567
  • 1
  • 6
  • 12
  • `gunzip file_to_archive.gz` – mailq Oct 14 '11 at 18:55
  • 1
    If you think you've screwed things up just restore from backup and remove all doubt. – John Gardeniers Oct 14 '11 at 19:12
  • `gzip` compresses individual files! That is why it is used together with `tar` to create those ubiquitous `.tar.gz` archives. – Skyhawk Oct 14 '11 at 19:13
  • Thanks John, I'm trying to get the backed up files restored now. But by way of better understanding how the stackoverflow sites work, why did I get a -1 for this? It seems a valid problem (though granted a stupid, self inflicted one). – doub1ejack Oct 14 '11 at 19:33
  • Not guilty. Downvotes are supposed to be for bad questions (poorly written, lack detail, etc.) but some people like to use them whenever they don't agree with the concept, regardless of whether the question is well written or not. You'll see that happen a fair bit around here. – John Gardeniers Oct 14 '11 at 19:54
  • Nice. Nothing like being kicked when you're down. – doub1ejack Oct 15 '11 at 22:22

1 Answers1

10

If you're sure everything in the web directory should be unzipped (e.g. nothing was zipped prior), you can use the 'find' utility like so:

find /web/root -type f -iname "*.gz" -exec gunzip {} \;

that will find:

  • all files (-type f)
  • in the web root (/web/root in the example)
  • with an extension of .gz (-iname "*.gz" which does case-insensitive search)

and executes the gunzip program on that file (the {} curly brackets are replaced by the file names that find matches). The backslash-escaped semicolon is required on the end in order to terminate the -exec statement.

There's other ways to do it using other command-line utilities or scripting languages - I tend to use find a lot so this one was easiest for me to describe.

Hope that helps!

haymaker
  • 1,250
  • 9
  • 9
  • 2
    I would add that in the future you should be *much* more careful about what you type/run: By not understanding what `gzip` did you created a mess. This could have been avoided by reading the manual for gzip (`man gzip`), which would have explained that it simply compresses all the files that you supply as arguments... – voretaq7 Oct 14 '11 at 19:08
  • voretaq7: actually, that dawned on me 13 minutes ago when I crashed the entire site. you are completely right though, of course. – doub1ejack Oct 14 '11 at 19:16