First of all this is not my code, I found it on this page via Google, while looking for something that would work like the 'tree' command in Windows.
This guy found a way to do so, using just ls, grep and sed; pretty neat! Here's the command:
You may wish to add | more at the end to page through the output. Or try using > ~/Desktop/mytree.txt at the end to dump the output to a file. I do not, however, recommend doing that with a huge directory such as Applications, unless you have some time to wait. I tried it, and after a few minutes of waiting, wound up with a 1.1mb text file containing 37,000+ rows!]
$ tree /Applications | more /Applications |-Address Book.app |---Contents |-----MacOS |-----Resources |-------ABLargeTypeWindow.nib etc...
Mac OS X Hints