LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Unzipping all .gz files in all subdirectories (https://www.linuxquestions.org/questions/linux-general-1/unzipping-all-gz-files-in-all-subdirectories-172263/)

darin3200 04-19-2004 07:44 PM

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. :rolleyes: 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,

ToniT 04-19-2004 08:36 PM

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.

darin3200 04-19-2004 08:58 PM

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?

ToniT 04-19-2004 11:45 PM

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.

ToniT 04-19-2004 11:47 PM

Does running one gunzip command manually work?

slick_willie 04-20-2004 06:30 AM

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

darin3200 04-23-2004 04:40 PM

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

ToniT 04-23-2004 10:26 PM

The command with those grep -Zz stuff works fine for me. Strange.

darin3200 04-24-2004 06:59 PM

I checked and the only files I have left that are .gz are in /usr/share/man, do these files need to be decompressed?

ToniT 04-24-2004 07:47 PM

They are compressed in my system (debian) and I think the man can uncompress them on the fly when needed.

darin3200 04-24-2004 09:58 PM

Maybe that's why it ignored some of the files. I got the system working, thanks for the help


All times are GMT -5. The time now is 08:38 AM.