Last Updated: February 25, 2016
· barnettjw

Draw Structure of Directory Hierarchy

Linux oneliner that draw's the structure of a directory Hierarchy using the magic of sed and dash of grep

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

And then you get this:



2 Responses
Add your response

Isn't there a built-in analog of DOS-like tree? I always thought that's weird, sounds like a common task...

over 1 year ago ·

There is a command tree however it's not part of a standard package, so you probably have to install it on most systems.

over 1 year ago ·