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:

mysite
|-- 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 4 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

DIR=${1:-`pwd`}
SPACING=${2:-|} 
cd $DIR 
for x in * ; do
  [ -d $DIR/$x ] && echo "$SPACING\`-{"$x && $0 $DIR/$x "$SPACING "
done
share|improve this answer

Your Answer

 
discard

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.