As I understand it the -depth
option of the find
command causes the specified actions to take place on the way out of a directory (and maybe I understand it wrong) during a depth-first traversal of a tree structure.
Without the -depth
option specified, does it normally make an action occur before the depth-first traversal is complete, or does it do a breadth-first traversal of the directories and run the action first normally?
Best Answer
find
uses a depth-first strategy (as opposed to breadth-first), whether-depth
is specified or not.-depth
only guarantees that sub-directories are processed before their parents.A quick example:
produces
whereas
produces
If you want breadth-first search, you can use
bfs
which is a breadth-first implementation offind
.