Python Forum
a tree command using Shell Script that displays all the directories recursively - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Forum & Off Topic (https://python-forum.io/forum-23.html)
+--- Forum: Bar (https://python-forum.io/forum-27.html)
+--- Thread: a tree command using Shell Script that displays all the directories recursively (/thread-35579.html)



a tree command using Shell Script that displays all the directories recursively - apollo - Nov-18-2021

Good day dear Python-experts, hello everyone


hope that youre all right and all goes well at your side.

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 this be achived?

note: i want to do this on a MX-Linux system - well i can do this with Tree - but wait. I guess that tree has to be installed first..


RE: a tree command using Shell Script that displays all the directories recursively - BashBedlam - Nov-18-2021

Here's one that's pretty close.

#!/usr/bin/env bash

# bash script to generate tree structure of a directory
# Pravendra Singh : https://pravj.github.io

pwd=$(pwd)
find $pwd -print | sed -e "s;$pwd;\.;g;s;[^/]*\/;|__;g;s;__|; |;g"