How it works...
The creation of mytree.sh is a trivial task, but the logic inside follows recursive functions. There is also the concept of ${CURRENT_LVL}, which is used to produce the number of periods (or levels) deep the script is from its original starting point: parentdir. In each directory, we create a for loop to test each file/directory inside of it. The logic tests whether the entry is either a file or a director. If it is a directory, we increment ${CURRENT_LVL} and then recursively execute the same logic inside of the recursive_tree function until done and then return. If the logic is a file, we merely print out and continue. The tab_creator function makes the variable string for the periods based on ${CURRENT_LVL} and concatenation. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access