CentOS 5.9
I've got a server with a foo.ext.gz file located in a variety of random directories.
Example:
- /opt/fooapp/foosubdirectory/foo_randomnumber/blah/blah/foo.ext.gz
- /opt/fooapp/foosubdirectory/foo_differentrandomnumber/blah/blah/foo.ext.gz
- /opt/fooapp/foosubdirectory/foo_anotherdifferentrandomnumber/blah/blah/foo.ext.gz
I'd like to run a bash command that will:
- Locate foo.ext.gz files
- Extract the contents of the gz file in the same directory that its respective GZ file resides in
- Keep the original gz file intact.
If I was doing this manually, I'd start with find / -iname foo.ext.gz
. After that, I'd copy the directory the file resides in and type something like:
gunzip -c /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext.gz > /opt/fooapp/foosubdirectory/foo_12345/blah/blah/foo.ext
The problem here is that I need to manually do this process for several dozen files/directories.
Is there a way I can leverage xargs or a for loop?