Predefined special variables in the Bourne shell
Several variables have special meanings. The following variables are set only by the Bourne shell:
| Item | Description |
|---|---|
| $@ | Expands the positional parameters, beginning with $1.
Each parameter is separated by a space. If you place double quotation
marks ( |
| $* | Expands the positional parameters, beginning with $1.
The shell separates each parameter with the first character of the IFS variable
value. If you place double quotation marks ( |
| $# | Specifies the number of positional parameters passed to the shell, not counting the name of the shell procedure itself. The $# variable thus yields the number of the highest-numbered positional parameter that is set. One of the primary uses of this variable is to check for the presence of the required number of arguments. Only positional parameters $0 through $9 are accessible through the shell. |
| $? | Specifies the exit value of the last command executed. Its value is a decimal string. Most commands return a value of 0 to indicate successful completion. The shell itself returns the current value of the $? variable as its exit value. |
| $$ | Identifies the process number of the current process. Because
process numbers are unique among all existing processes, this string is often
used to generate unique names for temporary files. The following example
illustrates the recommended practice of creating temporary files in a directory
used only for that purpose:
|
| $! | Specifies the process number of the last process run in
the background using the & terminator. |
| $- | A string consisting of the names of the execution flags currently set in the shell. |