Module Title: dgt_bash03 – Syntax
Description:
“dgt_bash03 – Syntax” covers Bash scripting, with a focus on syntax. It is intended for learners who have some exposure to shell scripts and want to learn the fundamental constructs used in Bash scripts.
In this module, you will study the details of Bash syntax through detailed explanations and real examples. We cover the essential control structures, including if, then, else, while, and for loops. You will not write these scripts yourself: you will describe the task to the machine in natural language, and it will write the script. Knowing the syntax is what lets you read every line it produces, spot an unquoted variable or a wrong test, and ask for exactly the right fix.
Key Learning Objectives:
- Conditional Statements
if,then,else: - Understand the syntax and semantics of conditional statements.
- Describe decision logic precisely enough that the machine’s script makes the right decision in every case, and verify that it does.
-
Read and check nested if-else statements for complex decision-making.
-
Loops
while,for: - Understand how while loops repeat until a condition is met, and recognize an infinite or off-by-one loop in generated code.
- Understand how for loops iterate over lists or ranges, and specify the iteration you want unambiguously.
-
Recognize how loop control statements like
breakandcontinuechange the flow, and ask for them where appropriate. -
Practical Examples:
- Instruct the machine to solve common scripting scenarios, then run and test the scripts it delivers.
-
Analyze scripts that use these constructs to solve real-world problems, explaining what each line does.
-
Best Practices:
- Learn the best practices that make scripts readable and maintainable, and require them in your instructions.
- Learn how to debug a failing script by reading its output and guiding the machine toward the fix.
By the end of this module, you will know the key syntactical constructs of Bash well enough to obtain robust, efficient scripts from the machine and to vouch for every line. This knowledge applies both to automating tasks on a system and to building more complex shell-based tools.
The students can push their exercises to the Academy DevOps & SRE Git project. For this module, create a folder with your username as its name in the following subfolder: https://github.com/Garanti-Del-Talento/gdt_academy
