Environment Variables
Table 2.4 shows a complete list of environment variables available in bash 2.0. The letters in the Type column of the table have the following meanings: A = Array, L = colon separated list, R = read-only, U = unsetting it causes it to lose its special meaning.
Note that the variables BASH_VERSINFO, DIRSTACK, GLOBIGNORE, GROUPS, HISTIGNORE, HOSTNAME, LANG, LC_ALL, LC_COLLATE, LC_MESSAGE, MACHTYPE, PIPESTATUS, SHELLOPTS, and TIMEFORMAT are not available in versions prior to 2.0. BASH_ENV replaces ENV found in earlier versions.
Table B-4. Environment Variables
| Variable | Chapter | Type | Description |
|---|---|---|---|
| * | 4 | R |
The positional parameters given to the current script or function. |
| @ | 4 | R |
The positional parameters given to the current script or function. |
| # | 4 | R |
The number of arguments given to the current script or function. |
| - | R |
Options given to the shell on invocation. | |
| ? | 5 | R |
Exit status of the previous command. |
| R |
Last argument to the previous command. | ||
| $ | 8 | R |
Process ID of the shell process. |
| ! | 8 | R |
Process ID of the last background command. |
| 0 | 4 | R |
Name of the shell or shell script. |
| BASH | 3 |
The full pathname used to invoke this instance of bash. | |
| BASH_ENV | 3 |
The name of a file to run as the environment file when the shell is invoked. | |
| BASH_VERSION | 3 |
The version number of this instance of bash. | |
| BASH_VERSINFO | 3,6 | AR |
Version information for this instance of bash. Each element of the array holds parts of the version number. |
| CDPATH | 3 | L |
A list of directories for the cd command ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access