This section describes the syntax of the Bourne Shell. It lists special characters, variables, and built-in programming commands used by the shell.
$ HOME/.profile
Executed at shell startup.
* |
Match any string of characters. |
? |
Match any single character. |
[ . . . ] |
Match any of the enclosed characters. A pair of characters separated by a minus will match any character lexically between the pair. |
variable = value |
Set variable to value. |
$ variable |
Use value of variable. |
$ variable-value |
Use variable if set; otherwise set to value. For example: TERM=$ {1: -$TERM} will set the TERM variable to the value of the first argument to a shell script, if given, or else to the existing (default) value of TERM . |
$ variable=value |
Use variable if not set; otherwise set to value. |
$ variable?value |
Use variable if set; otherwise print value then exit. |
$ variable+value |
Use value if variable is set; otherwise nothing. |
If the colon (:) is included in these expressions, a test is performed to see if the variable is non-null as well as set.
$# |
Number of command-line arguments. |
$– |
Options supplied in invocation or by the set command. |
$? |
Return value of last executed command. |
$$ |
Return process number of current process. |
$! |
Return process number of last background command. |
profile
$HOME |
Default (home directory) value for the cd command. |
$IFS |
Internal field separators. |
$MAIL |
Default mail file. |
$PATH |
Default search path for commands. |
$PS1 |
Primary prompt string; default is $ . |
$PS2 |
Secondary prompt string; default is > . |
$TERM |
Specifies the type of terminal. |
—- |
Don’t treat subsequent arguments beginning with – as options. |
—a |
Automatically export all subsequently defined variables. |
—e |
Exit shell if any command has a nonzero exit status. |
—k |
Put keywords in an environment for a command. |
—n |
Read but do not execute commands. |
—t |
Exit after one command is executed. |
—u |
Treat unset variables as an error. |
—v |
Print commands as they are executed. |
—x |
Turn on trace mode in current shell (echo commands in scripts as they are executed). |
arg ...
Assigned in order to $1, $2, ... $9
.
shift |
shift Perform a shift for arguments, e.g., $2 becomes $1 . |
test |
test exp | [exp]Evaluate the expression exp. An alternate form of the command uses [ ] rather than the word test. The following primitives are used to construct expression. |
13.58.150.59