Bash - Special Parameter

1 - About

Special parameters are Parameters treated specially. metacharacter ??

These parameters may only be referenced; assignment to them is not allowed.

3 - List

3.1 - Positional parameters Expansion

Positional parameter expansion

  • Star (*)
  • At (@)
  • Hash (#)

3.2 - Exist Status

? expands to the status of the most recently executed foreground pipeline.

echo $?
0 # All good

3.3 - Shell Option

- expands to the current option flags. See Bash - Shell Option (Shopt)

echo $-

3.4 - Process

3.4.1 - Dollar ($)

$ expands to the process ID of the shell. In a () subshell, it expands to the process ID of the current shell, not the subshell.

echo $$

3.4.2 - Exclamation mark (!)

! expands to the process ID of the most recently executed background (asynchronous) command.

3.5 - Script

0 Expands to the name of the shell or shell script.

3.5.1 - Underscore

_ At shell startup, set to the absolute pathname used to invoke the shell or shell script being executed as passed in the environment or argument list.

Subsequently, expands to the last argument to the previous command, after expansion. Also set to the full pathname used to invoke each command executed and placed in the environment exported to that command. When checking mail, this parameter holds the name of the mail file currently being checked.

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap