Interview Prep/Shell Scripting/Shells, scripts and execution

What do `$0`, `$1`, `$#`, `$@`, `$*`, `$?`, `$$`, `$!` and `$-` contain?

BeginnerConceptShells, scripts and execution
Answer
Variable Meaning
$0 Script name as invoked
$1..$9, ${10} Positional arguments (braces needed from 10)
$# Number of arguments
"$@" All arguments, each as a separate word
"$*" All arguments joined into one word with the first char of IFS
$? Exit status of the last command
$$ PID of the current shell (the parent, even inside a subshell)
$! PID of the last background job
$- Current option flags, e.g. hB or ehuB

$BASHPID gives the real PID inside a subshell.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Shells, scripts and execution