Magic Variables in Bash
-
$0-$99x-th argument provided to the script/function.$0is always the script name even when accessed from within a function.$1+will work in functions. -
$?Exit code of the last process. -
$_Last argument. -
$!PID of last process. -
$@All arguments.
Note: Always quote variables to avoid word-splitting (except when using [[ for tests). Run shellcheck to make sure.