'Combine two find commands

I'm looking to find the folder named - secrets, under /home/build, if found, check if it has a tar.gz file under it, recursively.

I tried some thing like below but it didn't work, how can I fix this ?

find -type d \( -name "secrets" \) -exec find . -type f -name "*.tar.gz"

OS - MacOS



Solution 1:[1]

this should work :

find -type d \( -name "secrets" \) -execdir find {} -type f -name "*.tar.gz" \;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Philippe