I want to simulate a tree
command using Shell Script that displays all the directories recursively in this format:
.
|-- Lorem
|-- Lorem
|-- Lorem
|-- Lorem
|-- Lorem
|-- Lorem
`-- Lorem
How can I do that?
I want to simulate a tree
command using Shell Script that displays all the directories recursively in this format:
.
|-- Lorem
|-- Lorem
|-- Lorem
|-- Lorem
|-- Lorem
|-- Lorem
`-- Lorem
How can I do that?
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^/]*//--/g' -e 's/^/ /' -e 's/-/|/'
taken from here: http://www.centerkey.com/tree/
You can just launch :
OR
If you want to display the hidden files.
By default tree does not print hidden files (those beginning with a dot '.'), just type:
This is what tree command do.
Modifying sputnick's answer to get closer to your original format (which I prefer):
The only difference now is the last line doesn't start with a backtick:
with awk
Try doing this (not exactly the same output, but very close) :
From http://mlsamuelson.com/content/tree-approximation-using-find-and-sed
with awk
See http://www.unix.com/shell-programming-scripting/50806-directory-tree.html
Modified base on the awk one from http://www.unix.com/shell-programming-scripting/50806-directory-tree.html
Output looks more similar to
tree
: