I've read through the man pages for tree but I don't know if it is possible to have tree list only the filenames for all files that appear in any recursive search of a directory.

The closest I have gotten is: tree -i --noreport dir/ which might give me something like:


Where order, lib, and rank are directories that I do not want listed.

  • What's the point of using tree if you don't want to see the directories? tree shows a hierarchical view of files and directories, if you remove the directories it cannot show a hierarchy and becomes useless. What exactly are you trying to do? – terdon Jan 26 '14 at 17:23

I think tree normally needs to print the directory name to get the tree-like structure.

How about using find instead?

find dir/ -type f

with above command you can get all and only files (-type f) recursively. It displays with path of the file, though.

In case that you don't want to display the path of the file, you can apply basename command at the end, like this:

find dir/ -type f -exec basename {} \;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.