Reputation: 237
I'm trying to write a script which will print directories, subdirectories and their files in a tree structure, but without using tree command.
Example:
DIR: A
f1
f2
DIR: B
f3
DIR: C
file1
file21
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?
Upvotes: 2
Views: 11957
Reputation: 2914
You may try variant of these command also
find . -type d -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
find . | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
find -type d
tree -l
Upvotes: 4