If (stem) tip(pipe) # if.: stem is empty at first!įor (d = 1 d < growth d++) stem = stem blankīelow = substr(stem, length(stem) - 4, 4) # gsub: count (and clean) all slash-ending components hence, # Model each stem on the previous one, going bottom up. First, an example of output:įunction tip(new) Įlbow = "└── " pipe = "│ " tee = "├── " blank = " " But, to improve on other answers that rely on grepping the output of ls -R, here is a shell script that uses awk to print a tree of subdirectories. For my use case I additionally removed the global indentation and added the option to also ls hidden files, like so: ls -aR | grep ":$" | sed -e 's/:$//' -e 's/*// /g' I still like Ben's solution in the comment of Hassou's answer very much, without the (not perfectly correct) lines it's much cleaner. Suggestions to avoid the superfluous vertical lines are welcome :-) Had to use perl though, but in my case, on the system where I don't have tree, perl is available. It's similar to the answer of Robert but the horizontal lines do not all start at the beginning, but where there are supposed to start. Since I was not too happy with the output of other (non- tree) answers (see my comment at Hassou's answer), I tried to mimic trees output a bit more.
0 Comments
Leave a Reply. |