2

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:

 .                          
 |-docs                     
 |-lib                      
 |-node_modules             
 |---connect-file-cache     
 |-----docs                 
 |-----lib                  
 |-----node_modules         
 |-------mime               
 |-------underscore         
 |-----src                  
 |-----test                 
 |-----test_fixtures        
 |---mime                   
 |---snockets               

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.

BenjiWiebe
  • 8,854
  • 11
  • 42
  • 65
jcollum
  • 4,963
  • 11
  • 46
  • 62
  • Does that work for you? (Second answer with the shell script) [Mac OS X equivalent of the Ubuntu “tree” command](http://superuser.com/questions/359723/mac-os-x-equivalent-of-the-ubuntu-tree-command/359727#359727) – 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
  • "I don't think I can get the tree command into mingw32" Yes you can, just put `alias tree=tree.com` in your ~/.bashrc – BenjiWiebe Jan 10 '13 at 19:01
  • @BenjiWiebe that is effectively the same as what I have already -- no files. – jcollum Jan 10 '13 at 22:39
  • @jcollum OK, try this in your .bashrc: `alias tree='tree.com /f'` – BenjiWiebe Jan 10 '13 at 22:41
  • @EBGreen from OP: "That's good, but the files aren't there" -- which also applies to the tree command from cmd. I can add a /f to the command, but then bash thinks I'm trying to tree the /f drive. – jcollum Jan 10 '13 at 22:44
  • @BenjiWiebe nope, bash thinks the /f is a drive letter. – jcollum Jan 10 '13 at 22:47
  • @jcollum Interesting. I never noticed that. – BenjiWiebe Jan 11 '13 at 00:22

2 Answers2

4

https://superuser.com/a/359728/5200

added this function to .bash_profile:

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

    if [ "$#" -gt 0 ] ; then
       dirlist="$@"
    else
       dirlist="."
    fi

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

}

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

jcollum
  • 4,963
  • 11
  • 46
  • 62
0

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