The Bourne shell has a number of special “automatic” variables that it maintains for informational purposes. These variables provide information such as the process ID of the shell, the exit status of the last command, and so on. This section provides a
list of these special variables. For additional variables supported by specific Bourne shell variants such as BASH and ZSH, see thebash andzshparam manual pages, respectively.
Table B-1 Special shell variables
|
Variable |
Description |
|---|---|
|
Process information | |
|
|
Process ID of shell |
|
|
Process ID of shell’s parent process. Quirk Warning:For subshells, the value of PPID is inherited from the parent shell. Thus, PPID is only the parent of the outermost shell process. |
|
|
Exit status of last command. |
|
|
Name of last command. |
|
|
Process ID of last process run in the background using ampersand (&) operator. This is commonly used in conjunction with the |
|
|
A colon-delimited list of locations where trusted executables are installed. Any executable in one of these locations can be executed without specifying a complete path. |
|
Field and record parsing | |
|
|
Input Field Separators (uses are explained in Variable Expansion and Field Separators) |
|
User information | |
|
|
The user’s home directory. |
|
|
The user’s ID. Security Warning:This value can be modified by the calling script, so it should not be used for authentication purposes. |
|
|
The user’s (short) login name. Security Warning:This value can be modified by the calling script, so it should not be used for authentication purposes. |
|
Miscellaneous Variables | |
|
|
Number of arguments passed to the shell. This variable is described further inHandling Flags and Arguments. |
|
|
Complete list of arguments passed to the shell, separated by spaces.. This variable is described further inHandling Flags and Arguments. |
|
|
Complete list of arguments passed to the shell, separated by the first character of the |
|
|
A list of all shell flags currently enabled. |
|
|
The current working directory. Equivalent to executing the |
《文章出处》
https://developer.apple.com/library/mac/documentation/OpenSource/Conceptual/ShellScripting/SpecialShellVariables/SpecialShellVariables.html
本文详细介绍了 Bourne Shell 中的各种特殊变量及其用途,包括进程信息、字段记录解析、用户信息及其它杂项变量。这些变量为 shell 脚本提供了重要的上下文信息。
211

被折叠的 条评论
为什么被折叠?



