Python Forum

Full Version: a tree command using Shell Script that displays all the directories recursively
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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..
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"