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. [...]
Try python -c ' import os for root, dirs, files in os.walk("."): if "file.txt" in files: dirs[:]=[] print(os.path.join(root, "file.txt"))' (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). -- Stephane