Using ls to display a file tree

Recently, I found a really elegant solution to display a file tree using the ls command. I like is so much that I feel the need to share it. The code is:

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

It displays files as follows:

.
|-application
|---configs
|---controllers
|---models
|---views
|-----helpers
|-----scripts
|-------error
|-------index
|-docs
|-library
|-public
|-tests
|---application
|---library

I got this code from http://www.centerkey.com/tree and you will also find a ready to go shell script there.

If you want to add this your bashrc to create an alias, you would run into your problem since bash doesn't allow single quotes inside inside single quotes even if they are escaped with backslash.

Technologies: