Bash - Special Parameter

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU)

1 - About

Special parameters are Parameters treated specially. metacharacter ??

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

Advertising

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 $-
himBH
Advertising

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

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.

lang/bash/special_parameter.txt · Last modified: 2018/09/16 12:42 by gerardnico