linuxfilefind

Recursive sorted file list (Linux)


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?


Solution

  • 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: