Description
It would be an interesting addition to the GNU find syntax to have some sort of possibility to evaluate parts of the find expression in context of a child/parent file.
If that's too confusing, a few examples in pseudo-find syntax with the proposed extension:
-
Exclude all directories containing a
CACHEDIR.TAG
file:find . -type d -child \( -type f -name CACHEDIR.TAG \) -prune -or ...
-
Find all directories that look like a Borg repository:
find . -type d -child \( -type f -name config -execdir grep -q -Fx '[repository]' {} \; \) -child \( -type d -name data \)
If this syntax is infeasible to implement efficiently due to requirement to perform nested iterations in general case, I can imagine another variant of this syntax:
find . -type d -child config \( -type f -execdir grep -q -Fx '[repository]' {} \; \) -child data \( -type d \)
In this case, the -child
operator has two operands: (1) a string representing a specific child file name to examine, and (2) a subexpression that is evaluated at most one time against the specific file named by the first operand (or not at all if there is no such file).