When find
iterates directories, they show up in the order the VFS yields them. Can this order be changed to first traverse directories before looking at files placed beside them?
The -depth
option is not the solution. It only changes
$ find
.
./afile
./directory
./directory/athirdfile
./other-directory
to
$ find -depth
./afile
./directory/athirdfile
./directory
./other-directory
(Note how only the second and third output line swapped places.)
This question instead seeks for a way to produce the following order.
./directory/athirdfile
./directory
./other-directory
./afile
You can get your customized output by using 2
find
commands. Firstfind
will get everything using-depth
except files in current directory and 2ndfind
will get just the files from current level.