Linux: Recursively Unzip All Files Into Their Existing Directory

linux-penguin

A backup of every file in every sub-directory created zipped archives of each individual file. This was not the intended result. To resolve this each file must be restored to it’s original location and remove the created archive.

Research directed me into a couple of different routes, that didn’t really work for me or produce the desired result.

Here is a script, I wrote that produced the desired result. It was tested successfully on RHEL 5.5.

 find . -name "*.gz" | xargs gunzip 

Basically, from the terminal prompt, this command will recursively find a file with file extension gz, unzip that file to original state within the same directory, then delete the archive, gz.

To verify that any gz file remain

 find . -name "*.gz" 

Resources
Gzip – Linux Commands
Xargs by example
Unzip Commands