I have a directory that contains many (>5000) folders:
folder1 folder2 folder3 ...
All of these folders have many subdirectories.
In a specific subdirectory of each folder, there might be a
If a folder contains a
tar.gz archive, it will only be one, and it will be in a specific subdirectory.
folder1/foo/baz.tar.gz folder2/bar/qux.tar.gz folder3 [no tar.gz file in this folder] ...
I need to write a bash script as to accomplish the following:
- I want to loop through each folder, find the
tar.gzarchive if it exists, and untar its contents in a different directory (which is the same for all found archives).
- Once every
tar.gzarchive is found, I need to also move more files in the same directory as the
tar.gzarchive, maybe needing to store the path of the archive.
I am able to list all of the archives with:
find . -name "*tar.gz"
I am wondering whether manipulating the obtained command is the most optimal solution, or looping through each directory would be better...
What would be the most optimal approach? How should it be carried out?