RSS feed
<< Wiki syntax -Textile- available now in JPublish | Home | SHIMO, an extremely well done CISCO compliant VPN Client for OSX >>

Display folder contents as a tree structure

A lot of times I had to do acrobatics to be able to display the contents of a UNIX folder as a tree.  Well, no more!

Looking for using the ls command in various combinations I found this command gem:

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
So for a folder where the standard: ls webapps/hello/ will display this:

WEB-INF   actions   content   pages     public    templates

The new command trick:  ls -R webapps/hello/ | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/', will display:

   |---/WEB-INF
   |-----classes
   |---/actions
   |---/content
   |---/pages
   |---/public
   |-----styles
   |---/templates


Neat, eh?

There is also a nice script wrapper for the above command, follow this link for more.

 



Re: Display folder contents as a tree structure

Uhm, ever heard of tree ?

Re: Display folder contents as a tree structure

so "uhm" ;) do I have to install Steve Baker's implementation for Linux in order to display a tree?I am referring to the one that was available at: ftp://mama.indstate.edu/linux/tree

And what about osx? I don't like installing an app every time I need to manipulate a text.

Also, I am working on osx and couldn't find the 'tree' command line. But maybe is me not being able to find it :)

Add a comment Send a TrackBack