Linux – Can ‘find’ or any other tool search for files breadth-first


Sometimes I know a file is not so deep away, but a very dense sub-directory does not allow me to find the files I want easily.

Can find (or any other tool) look for files using breadth-first search?

Best Solution

Yes, sort of.

You can use the -depth option to make it process a directory's contents before the directory itself. You can also use the -maxdepth option to limit how many directories down it will drill.