Recently I found myself looking for all the files of the same name & subpath. For context, it’s a GitOps (or CI-Ops, if you’re from the weaveworks gang πŸ˜›) repository, where the root directories are k8s clusters and the inner directories are components, with the leaf file being the helmfile we use for deployments.

So a simplified structure would look something like:

.
β”œβ”€β”€ cluster-A
β”‚Β Β  β”œβ”€β”€ component-1
β”‚Β Β  β”‚Β Β  └── helmfile-012.yaml
β”‚Β Β  └── component-2
β”‚Β Β      └── helmfile-023.yaml
β”œβ”€β”€ cluster-B
β”‚Β Β  β”œβ”€β”€ component-1
β”‚Β Β  β”‚Β Β  └── helmfile-034.yaml
β”‚Β Β  └── component-2
β”‚Β Β      └── helmfile-045.yaml
└── cluster-C
    β”œβ”€β”€ component-1
    β”‚Β Β  └── helmfile.yaml
    └── component-2
        └── helmfile.yaml

Easiest way to find all helmfile.yaml files for component-1 in all clusters?

find . -path "*/cluster*/component-1/*.yaml"

And this would yield:

./cluster-A/component-1/helmfile-012.yaml
./cluster-C/component-1/helmfile-034.yaml
./cluster-B/component-1/helmfile.yaml

Et voilΓ !