Lesson 22: Script Arguments
The backup script backs up a hardcoded path. In DevOps — we run it on different directories each time. We'll pass the path as an argument. `$1` is the first argument; `$2` the second; `$#` — the argument count; `$@` — all of them. `$0` is the script name itself. First thing in a script — always chec
$1 is like a note you hand to a courier — whatever was written after the script name: in `./backup.sh /app`, $1 is /app. $# counts how many notes were handed over, $@ holds all of them, and $0 is the script's own name.
- positional parameters
- $1, $2, $3 ... — values of arguments passed to the script by position. $0 = the script name. $# = number of arguments. $@ = all arguments as a list. Always check the user passed enough arguments before using them.