Table of Contents

About

Special parameters are Parameters treated specially. metacharacter ??

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

List

Positional parameters Expansion

Positional parameter expansion

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

Exist Status

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

echo $?
0 # All good

Shell Option

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

echo $-
himBH

Process

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 $$
1

Exclamation mark (!)

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

Script

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

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.