I have a directory tree whose overall structure is something like
logs/
u1/
p1/q1/r1/info
p2/q2/info
u2/
p1/q1/r1/info
p3/info
p4/q4/r4/info
p4/q4/r4/s4/info
u3/
p1/noninfo
p2/q2/info
and I want to write a find invocation that e.g. returns all of the
info files contained in a p1/q1/r1 subdirectory while pruning as much of the search
exploration as possible (crucial given the large number of files).
So far I have
find -mindepth 2 -not -path "logs/*/p1*" -prune -o -wholename "*/p1/q1/r1/info" -print
where
-not -path "logs/*/p1*" -pruneensures we prune off everything that does not start withp1-mindepth 2ensures that e.g.logs/u1is not pruned off by the previous predicate-wholenamethen is what I am really looking for
Although that already cuts the search space down by quite a bit, I’m still exploring a lot of subdirectories that are already doomed.
At a very high level, I basically want to be able to specify a regex for each successive directory nesting. Can I do that in find (or something similarly widely available; I don’t really get to dictate what’s installed on the box this will run on)?