Linux: Get a tree-view of your directories

To my surprise there is one thing Windows has, that Linux lacks: A graphical tree-view of a given directory-structure. On Windows it’s as simple as typing “tree”. But as always on Linux, one could grab the necessary building-blocks and combine them to get what we need.

On http://www.centerkey.com/tree/ I found this nice one-liner based on “ls”,”grep” and “sed”:

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

Example:

[apache]$ ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
   .
   |-descriptor
   |-doc
   |-io
   |---export
   |---import
   |-languages
   |-skins
   |-specials
   |---SMWCheckInstallation
   |-tools
   |---maintenance
   |-----export
   |-----resources
   |-------dd_templates
   |---onto2mwxml
   |---smwadmin

There is another approach here, which I didn’t checked.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: