[Top][All Lists]

[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: Peng Yu
Subject: Re: The quickest way to not to descend into sub-directories once a file is found?
Date: Wed, 2 Oct 2019 17:10:25 -0500

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.

On Wed, Oct 2, 2019 at 4:25 PM Bernhard Voelker <address@hidden>

> On 2019-09-27 17:26, Peng Yu wrote:
> > On 2019-09-27 09:49, Stephane Chazelas wrote:
> >> Here, you could do:
> >>
> >> find . -type d -exec test -e '{}/file.txt' \; -prune -printf
> '%p/file.txt\n'
> >>
> >> But note that it involves forking a process and executing a test
> >> command in it for each non-pruned directory, which may end-up
> >> being less efficient than traversing the directories that a
> >> file.txt in them.
> [...]
> > But wouldn't a scripting language be less efficient than C
> implementation?
> There's a saying in the computing world:
> "premature optimization is the root of all evil".
> Actually, Stephane's example is similar to what is documented
> for a similar case here:
> https://www.gnu.org/software/findutils/manual/html_node/find_html/Finding-the-Shallowest-Instance.html
> I don't think one exec per directory is that bad.
> Please check (and report numbers in case of extraordinarily slow
> performance).
> Have a nice day,
> Berny

reply via email to

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