Introduction
In this challenge, we will learn about recursive functions in bash scripting. We will create a function that will print each argument passed to the function using recursion. We will pass command-line arguments to the script, and the script will call the function with the same arguments. Regardless of how many arguments are passed, we will only echo the first positional argument using recursion.
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
shell(("`Shell`")) -.-> shell/ControlFlowGroup(["`Control Flow`"])
linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"])
linux(("`Linux`")) -.-> linux/InputandOutputRedirectionGroup(["`Input and Output Redirection`"])
shell(("`Shell`")) -.-> shell/BasicSyntaxandStructureGroup(["`Basic Syntax and Structure`"])
shell(("`Shell`")) -.-> shell/VariableHandlingGroup(["`Variable Handling`"])
shell(("`Shell`")) -.-> shell/FunctionsandScopeGroup(["`Functions and Scope`"])
shell(("`Shell`")) -.-> shell/AdvancedScriptingConceptsGroup(["`Advanced Scripting Concepts`"])
shell(("`Shell`")) -.-> shell/SystemInteractionandConfigurationGroup(["`System Interaction and Configuration`"])
shell/ControlFlowGroup -.-> shell/if_else("`If-Else Statements`")
linux/BasicSystemCommandsGroup -.-> linux/exit("`Shell Exiting`")
linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`")
linux/InputandOutputRedirectionGroup -.-> linux/redirect("`I/O Redirecting`")
linux/BasicSystemCommandsGroup -.-> linux/bc("`Arithmetic Calculations`")
shell/BasicSyntaxandStructureGroup -.-> shell/shebang("`Shebang`")
shell/BasicSyntaxandStructureGroup -.-> shell/comments("`Comments`")
shell/BasicSyntaxandStructureGroup -.-> shell/quoting("`Quoting Mechanisms`")
shell/VariableHandlingGroup -.-> shell/variables_decl("`Variable Declaration`")
shell/VariableHandlingGroup -.-> shell/str_manipulation("`String Manipulation`")
shell/VariableHandlingGroup -.-> shell/arrays("`Arrays`")
shell/VariableHandlingGroup -.-> shell/param_expansion("`Parameter Expansion`")
shell/ControlFlowGroup -.-> shell/for_loops("`For Loops`")
shell/ControlFlowGroup -.-> shell/cond_expr("`Conditional Expressions`")
shell/ControlFlowGroup -.-> shell/exit_status("`Exit and Return Status`")
shell/FunctionsandScopeGroup -.-> shell/func_def("`Function Definition`")
shell/AdvancedScriptingConceptsGroup -.-> shell/arith_expansion("`Arithmetic Expansion`")
shell/AdvancedScriptingConceptsGroup -.-> shell/subshells("`Subshells and Command Groups`")
shell/SystemInteractionandConfigurationGroup -.-> shell/globbing_expansion("`Globbing and Pathname Expansion`")
subgraph Lab Skills
shell/if_else -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
linux/exit -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
linux/echo -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
linux/redirect -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
linux/bc -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/shebang -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/comments -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/quoting -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/variables_decl -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/str_manipulation -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/arrays -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/param_expansion -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/for_loops -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/cond_expr -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/exit_status -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/func_def -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/arith_expansion -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/subshells -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
shell/globbing_expansion -.-> lab-18293{{"`Recursive Function in Bash Scripting`"}}
end