title: Linux command to print a tree like directory structure
body: <p>I'm trying to write a script which will print directories, subdirectories and their files in a tree structure, but without using tree command.</p>
  
  <p>Example:</p>
  
  <pre><code>DIR: A 
       f1
       f2 
       DIR: B
            f3 
  DIR: C
       file1
       file21
  </code></pre>
  
  <p>I have tried multiple of solutions, but I always ran into the problem that I could not distinguish between a directory or a file, therefore I could not apply the right formatting. The "DIR: " prefix makes it complicated. Is there something very obvious that I'm missing?</p>