[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
Re: The quickest way to not to descend into sub-directories once a file is found?
Wed, 2 Oct 2019 23:25:58 +0100
2019-10-02 17:10:25 -0500, Peng Yu:
> 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.
python -c '
for root, dirs, files in os.walk("."):
if "file.txt" in files:
(note that it doesn't check that "file.txt" is a *regular* file,
only that it's not a directory (it may still be a symlink to a
directory); while that could be added, I don't expect you would
care much about it).