I want to simulate a tree command using Shell Script that displays all the directories recursively in this format:
.
|-- Lorem
|-- Lorem
|-- Lor
Modifying sputnick's answer to get closer to your original format (which I prefer):
find ./ -type d -print | sed -e 's;[^/]*/; /;g;s;/ ; ;g;s;^ /$;.;;s; /;|-- ;g'
The only difference now is the last line doesn't start with a backtick:
.
|-- Lorem
|-- Lorem
|-- Lorem
|-- Lorem
|-- Lorem
|-- Lorem
|-- Lorem
find . -type d -print 2>/dev/null | awk '!/\.$/ {for (i=1;i