Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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..

share|improve this question

closed as off topic by Shane Madden, Chris S, John Gardeniers, Skyhawk, Ward Oct 14 '11 at 19:13

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
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
show 1 more comment

1 Answer

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!

share|improve this answer
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
add comment

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