Skip to content

RFE: child/parent operators #141

Open
@intelfx

Description

@intelfx

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:

  1. Exclude all directories containing a CACHEDIR.TAG file:

    find . -type d -child \( -type f -name CACHEDIR.TAG \) -prune -or ...
  2. 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).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions