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 'first argument' — what you typed after the script name. `./backup.sh /app` → $1 = /app. $# = how many arguments. $@ = all of them. $0 = the script 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.