LLI Wiki — My Digital Knowledge Base

Bash special parameters: $?, $0, $#, $$

Quick reference to the Bash special parameters for the exit status, script name, argument count and shell process ID.

Bash exposes a few special parameters that report the state of the shell and of the running script.

Parameter Meaning
$? Exit status of the last command executed.
$0 File name of the current script.
$# Number of arguments supplied to the script.
$$ Process ID of the current shell. In a shell script, this is the process ID under which the script runs.
Mastodon LLIMastodon SocialFosstodon