Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can you pretty print a directory structure with all subdirectories to the deepest level in the linux terminal(ubuntu)? This is an example of such a pretty print output for a mysite folder:

|-- manage.py
|-- mysite
    |-- __init__.py
    |-- settings.py
    |-- urls.py
    |-- wsgi.py
|-- polls
    |-- __init__.py
    |-- models.py
    |-- tests.py
    |-- views.py
    |-- static
        |-- css
            |-- styles.css
|-- templates
    |-- polls
        |-- index.html
share|improve this question

2 Answers 2

up vote 9 down vote accepted

You can use the tree command. You might need to install it if it is not already installed.

share|improve this answer
Awesome, thanks!!! –  Bentley4 Jul 23 '12 at 11:56

A shell only version, usage: dirtree

cd $DIR 
for x in * ; do
  [ -d $DIR/$x ] && echo "$SPACING\`-{"$x && $0 $DIR/$x "$SPACING "
share|improve this answer
Hard to follow this, and hard to use. It doesn’t want to run for me. (I’m not on ubuntu though, but this looks portable enough.) What do you mean, usage: dirtree? –  Alan H. Aug 6 at 17:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.