I want to recurse through a directory, including in subdirectories and subdirectories of those and so on, printing out only file names (no directories). I would also like to have the results on a new line each and sorted.
Please note that ls -LR
or ls -xLR
doesn't work as ls
formats the result into a sort of table.
How can it be achieved?
Go to the directory you want to search in, and run:
find . -type f -exec basename {} \; | sort
Sorted by name, just filenames (no paths), and just files (no directories).
Details:
find
works recursively, by default. -type f
will print only files, not directories. -exec basename
runs basename
on the results (so paths are not printed).sort
will sort the results (D'Oh!)