Lesson 23: Bash Functions
The backup script grows — the tar line repeats in multiple places. In DevOps — copied code is code someone will forget to update. A function lets you write logic once and call it by name: `backup() { ... }`. `$1` inside the function holds the argument passed at the call — not the script's own argume
A function = a named recipe. `backup() { tar ... "$1"; }` is the recipe. `backup /var/log` means 'run the recipe for /var/log'. $1 inside the function = what you passed in the call.
- bash function
- A named block of commands: `name() { commands; }`. Define once, call by name (`name arg`). $1 inside the function is the argument passed at the call — not the script's own arguments.