ShellTree 6: Further Optimization by Removing Changes to IFS

This post is part of an educational series on building a shell script to graphically display the structure of a directory. Previously We broke down Dem Pilafian’s one line command to display a tree of a directory We broke down Dem Pilafian’s script that uses the one line command We modified the one line to…

ShellTree 5: Optimizing the Recursive Script by Removing Arrays and Adding a String

This post is part of an educational series on building a shell script to graphically display the structure of a directory. Previously We broke down Dem Pilafian’s one line command to display a tree of a directory We broke down Dem Pilafian’s script that uses the one line command We modified the one line to…

ShellTree 4: Building a New Recursive Script

This post is part of an educational series on building a shell script to graphically display the structure of a directory. Previously We broke down Dem Pilafian’s one line command to display a tree of a directory We broke down Dem Pilafian’s script that uses the one line command We modified the one line to…

Bash Recursion Examples and Experiments with Local Variables

Recursion in programming is when a piece of code (usually a function) calls itself. If there is no exit case, the program will go on forever. We will be discussing recursion in a bash script with examples and discussing some peculiarities of the bash shell, such as local variables. Setup Let’s make a shell script.…

Bash Arrays 5: Local Arrays in Recursive Functions

When making a bash recursive function we have to pay special attention to local variables. One special case is when we wish to pass an array to a recursive function. When making recursive function, we have to be careful how we use variables. This post will deal with passing arrays as parameters to recursive functions.…