I've found this command to show a tree of the directories under the current one:

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'         

Which produces:


That's good, but the files aren't there. My bash scripting skills are weak, so I have no idea how to get the files to show in that output.

Since I'm on Windows, I don't think I can get the tree command into mingw32.

  • Does that work for you? (Second answer with the shell script) Mac OS X equivalent of the Ubuntu “tree” command – slhck Jan 10 '13 at 18:52
  • 3
    What is wrong with the tree command in the cmd propmpt on your windows box? – EBGreen Jan 10 '13 at 18:54
  • @EBGreen If the OP wants the files to show, he should use (Command Prompt) tree /f – BenjiWiebe Jan 10 '13 at 18:56
  • @BenjiWiebe that is why I asked what is wrong with the windows tree command. – EBGreen Jan 10 '13 at 18:57
  • @EBGreen I meant that if the OP did not like tree, he should use tree /f to display the files, not just the directories. – BenjiWiebe Jan 10 '13 at 18:59


added this function to .bash_profile:

function ftree {
    SEDMAGIC='s;[^/]*/;|____;g;s;____|; |;g'

    if [ "$#" -gt 0 ] ; then

    for x in $dirlist; do
         find "$x" -print | sed -e "$SEDMAGIC"


It's not pretty, but it does the job. Credit to https://superuser.com/users/105575/ahmed-masud

  • Any idea how to color code the directories to a different color? Or reuse your directory listing colors? – Jen S. Sep 23 '14 at 5:45
  • Sorry, no. Sounds like a good question on its own though. – jcollum Sep 23 '14 at 15:55

A tool that will help you with this is Print Maestro. This handy solution will quickly print folder tree after preview.

When you click on some folder in the left-side folder list, you will see all its subfolders listed in the upper right side list. Below it you will find the report mock that will be printed. To the right from the mock there is a list of report types, where you need to check off 'Tree' in Standard tab.

Print Folder Tree

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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