Tree is a recursive directory listing program that produces a depth indented listing of files. With no arguments, tree lists the files in the current directory.

It has a simple problem….

it is not present on Mac OS X Mavericks…..

 

First way:

if you have installed a package manager you could use it to install the tree command.
If you have installed brew
# brew install tree

if you have installed mac ports
# sudo port install tree

if you have installed fink
# fink install tree

bash
way 2: Using sed

a simple sed script can help you:
SEDTREE='s;[^/]*/;|____;g;s;____|; |;g'

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

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

Way 3: using awk

find . -print 2>/dev/null | awk '!/\.$/ { \
for (i=1; i<NF; i++) { \
printf("%4s", "|") \
} \
print "-- "$NF \
}' FS='/'

 

you can save the scripts as tree in /usr/local/bin/ and then invoke it from the command line

 

Gg1