Jump to content

simulate a tree command using Shell Script that displays all the directories recursively


malaga

Recommended Posts

 

Good day dear Armbian-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..

Link to comment
Share on other sites

1. Not sure what you are trying to do, but tree have a lot of command line options.

 

2. Surely it is open source, go look up sources to study implementation details?

 

27 minutes ago, malaga said:

i want to do this on a MX-Linux system

 

3. This has nothing to do with Armbian, maybe try #linux on libera.chat or (any of the many, many) other general Linux resources on the Internet.

Link to comment
Share on other sites

hello dear TRS-80 

 

first of all - many many thanks for the quick reply.  You were right.

 

This is not focussed on the Armbian - i am sorry that i was posting anything against the forum rules. 

 

Sorry. - i will try to figure it out - and will read some manpages. 

 

Again - sorry for the posting.  I am very glad to be part of this great Community - i am a big big Armbian-Fan. 

 

have  a great day. 

 

 

Link to comment
Share on other sites

find . -type d | awk -F/ '{printf("%"4*NF"s|-- %s\n", " ",$NF)}'

 

(find in current dir all files of type directory and process them threw awk with "/" field separator to print a space with 4 times number of fields width, then a bar and two dash and the last field.

 

awk is your friend

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines