Finding files/dirs with common subpath
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Γ !