Shell Scripting Study Guide
Introduction
This folder provides a systematic study of shell scripting as a programming discipline. Using Bash as the primary shell, it covers advanced techniques, real-world automation patterns, and professional best practices that go well beyond basic scripting.
Target audience: Learners who have completed the Linux topic (especially Lesson 09: Shell Scripting basics)
Learning Roadmap
[Foundation] [Intermediate] [Advanced]
| | |
v v v
Shell Basics/Env ------> Functions/Libs ---------> Portability/Best Practices
| | |
v v v
Parameter Expansion ----> I/O & Redirection ------> Testing
| |
v v [Projects]
Arrays & Data ----------> String/Regex ----------> Task Runner
| | |
v v v
Adv. Control Flow ------> Process/Error ----------> Deployment
| |
v v
Arg Parsing/CLI ---------> Monitoring Tool
Prerequisites
File List
Foundation (Review + Beyond Basics)
| File |
Difficulty |
Key Topics |
| 01_Shell_Fundamentals.md |
⭐ |
Shell types (bash/sh/zsh/dash), POSIX, login/non-login, profile/bashrc loading, exit codes |
| 02_Parameter_Expansion.md |
⭐⭐ |
String manipulation, ${var#}, ${var//}, substring, indirect refs, declare |
| 03_Arrays_and_Data.md |
⭐⭐ |
Associative arrays, stack/queue simulation, CSV parsing, config loading |
| 04_Advanced_Control_Flow.md |
⭐⭐ |
[[ ]] vs [ ] vs (( )), extglob, select menus, arithmetic with bc |
| File |
Difficulty |
Key Topics |
| 05_Functions_and_Libraries.md |
⭐⭐ |
Return patterns, recursion, function libraries, namespacing, callbacks |
| 06_IO_and_Redirection.md |
⭐⭐⭐ |
File descriptors, here documents, process substitution, named pipes, pipe pitfalls |
| 07_String_Processing.md |
⭐⭐⭐ |
Built-in string ops, printf, tr/cut/paste/join, jq/yq for JSON/YAML |
| 08_Regex_in_Bash.md |
⭐⭐⭐ |
=~ operator, BASH_REMATCH, extended regex, glob vs regex, practical validation |
| 09_Process_Management.md |
⭐⭐⭐ |
Background jobs, subshells, signals & trap, cleanup patterns, coproc |
| 10_Error_Handling.md |
⭐⭐⭐ |
set -euo pipefail deep dive, trap ERR, error frameworks, ShellCheck, logging |
| 11_Argument_Parsing.md |
⭐⭐⭐ |
getopts, getopt, self-documenting help, color output, progress bars |
Advanced (Professional Techniques)
Projects (Real-World Applications)
Recommended Learning Order
- Foundation (Week 1): 01 → 02 → 03 → 04
- Quickly review shell basics, then dive into parameter expansion and arrays
- Intermediate (Week 2-3): 05 → 06 → 07 → 08 → 09 → 10 → 11
- Core scripting techniques: I/O, regex, processes, error handling
- Advanced (Week 4): 12 → 13
- Portability, best practices, and testing
- Projects (Week 5): 14 → 15 → 16
- Apply everything in real-world projects
Practice Environment
# Check your bash version (4.0+ recommended for associative arrays)
bash --version
# Install ShellCheck for static analysis
# macOS
brew install shellcheck
# Ubuntu/Debian
sudo apt install shellcheck
# Install Bats for testing (Lesson 13)
brew install bats-core # macOS
# or from source: https://github.com/bats-core/bats-core
- Linux/ - Linux fundamentals, shell basics
- Git/ - Version control (scripts often used in Git hooks)
- Docker/ - Container entrypoints use shell scripts
- MLOps/ - Automation pipelines
References