LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-19-2004, 07:44 PM   #1
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Rep: Reputation: 45
Unzipping all .gz files in all subdirectories


I was trying to make a backup of my system last night and I screwed up the gzip command and ended up compressing over half the files in my system. I was able to 'gunzip *.gz' to my /bin and most of my /etc so I can boot but there are still a lot of .gz files in /usr and others. Is there a way to go through all subdirectories and gunzip all files ended in .gz? Or maybe even exclude all the one's with .tar.gz?
Thanks,
 
Old 04-19-2004, 08:36 PM   #2
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Code:
find -name '*.gz' | grep -v tar.gz | xargs -n1 echo gunzip
If that looks fine, take the 'echo' word away so it actually runs those commands instead of printing them to the screen.
 
Old 04-19-2004, 08:58 PM   #3
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
Ok, I tried that but it would only list the files in my current directory so I made the slight change to "find / -name '*.gz' | grep -v tar.gz | xargs -n1 echo gunzip" The command then will list all the files so I took out the echo before gunzip and it will list the .gz file followed by "is not a directory or a regular file - ignored" How do I get it to unzip those files?

Last edited by darin3200; 04-19-2004 at 09:02 PM.
 
Old 04-19-2004, 11:45 PM   #4
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Have you spaces in the files or directories?
If so,
Code:
find / -name '*.gz' -print0 | grep -Zzv tar.gz | xargs -0 -n1 echo gunzip
should do it.
 
Old 04-19-2004, 11:47 PM   #5
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Does running one gunzip command manually work?
 
Old 04-20-2004, 06:30 AM   #6
slick_willie
Member
 
Registered: May 2003
Posts: 46

Rep: Reputation: 15
maybe write a little script, I've read gunzip doesn't take well to pipeing make sure to log in as su so no permission denied files come up.
for FILENAME in `find -name *tar.gz -print`
do
gunzip $FILENAME
done
 
Old 04-23-2004, 04:40 PM   #7
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
Sorry it took me so long to reply, to ToniT: There aren't spaces and I get the same error with the new command and yes one gunzip command manually works. To slick_willie: Putting in a script simply printed out the gunzip command useage.
Thanks for all the help so far
 
Old 04-23-2004, 10:26 PM   #8
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
The command with those grep -Zz stuff works fine for me. Strange.
 
Old 04-24-2004, 06:59 PM   #9
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
I checked and the only files I have left that are .gz are in /usr/share/man, do these files need to be decompressed?
 
Old 04-24-2004, 07:47 PM   #10
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
They are compressed in my system (debian) and I think the man can uncompress them on the fly when needed.
 
Old 04-24-2004, 09:58 PM   #11
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
Maybe that's why it ignored some of the files. I got the system working, thanks for the help
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unzipping files??? linuxnoob1 Linux - Newbie 11 05-24-2005 01:30 AM
Unzipping .zip files in linux dr_zayus69 Linux - Software 5 09-27-2004 06:47 PM
unzipping files using bz2 bruce64 Linux - Software 6 07-17-2003 02:51 PM
delete files / keep subdirectories? lhorstman Linux - Newbie 2 01-10-2003 03:01 PM
unzipping .zip files...how?? Robert0380 Linux - General 2 04-11-2002 04:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration