unix - find command: conditionally prune subdirectories of any directory containing a matched file -


i'd search directory tree regular files matching particular patterns, e.g.

find -regex '.*\.\(expect\|missing\|ok\)' 

this fine, in application inefficient -- since if directory contains @ least 1 matching file, none of (many, deep, file-laden) subdirectories need searched, since won't contain matches.

so how -prune subdirectories, only if matched file found in parent directory?

e.g. if have following tree:

./a/file.ok ./a/a1/ ./a/a2/ ./b/file.missing ./b/file.expect ./b/b1/ ./b/b2/ ./c/c1/ ./c/c1/c11/ ./c/c1/c11/foo.expect ./c/c1/c11/foo.txt 

then print only:

./a/file.ok ./b/file.missing ./b/file.expect ./c/c1/c11/foo.expect 

without searching/traversing subdirectory trees of a/ , b/

(this earlier question approaches want, hasn't yet been answered.)


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -