bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The quickest way to not to descend into sub-directories once a file


From: Bernhard Voelker
Subject: Re: The quickest way to not to descend into sub-directories once a file is found?
Date: Wed, 9 Oct 2019 00:15:07 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0

On 2019-10-03 00:10, Peng Yu wrote:
> I’ve checked this many years ago. One directory exec is not acceptable in
> my case. I ended up with two pass, one to check which directory to include
> and exclude, then search for files in the directory included. But I am
> looking for something better.

The problem with a test like "-name 'file.txt'" is that find is already
visiting() a directory level too deep for a subsequent action to be
effective.

For your special case, you could try to locally add a new '-child PATTERN'
predicate which could check for the existence below the current entry.
A subsequent -prune would then skip that directory.

I'd consider your use-case not common enough to add such an option to GNU find,
as the existing solution via "-exec test -f '{}/file.txt' \;" seems to be 
sufficient
for most cases.

Have a nice day,
Bern



reply via email to

[Prev in Thread] Current Thread [Next in Thread]