Why is `find -depth 1` so slow to list directories? Why is `find -depth 1` so slow to list directories? bash bash

Why is `find -depth 1` so slow to list directories?


-depth does not stop at a single layer, you want -maxdepth for that. Instead it tells find to process the directories contents before itself, i.e., a depth first search.

Try instead

find . -maxdepth 1 -type d

it will find more than ls -F | grep / because it will also search "hidden" files, and for my example it was ever so slightly faster (0.091 seconds compared to 0.1).