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 is a named recipe: `backup() { tar … "$1"; }` is the recipe, and `backup /var/log` means 'make the recipe for /var/log'. Inside the function, $1 is whatever 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.