Print Directory tree

Reference Link

$ ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
   |-Application Support
   |---AddressBook
   |-----Images
   |---Adium 2.0
   |-----Contact List
   |-----Emoticons
   |-----Message Styles
   |-----PlugIns
   |-----Scripts

One may also save this command line as ~/bin/tree then one can just type

$ tree ./

What I did is making an alias:

$ vi ~/.bashrc
alias tree="ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'"
$ tree

only display the folders with depth < 3

tree | perl -pe "s/^.*\|-{5,}[^-].*\n//;" | grep "-"
Homepage
Comments

Hide Comments