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
