|
QuotingFour different types of quoting mechanisms are recognized. These are summarized in Table A.5.
Tilde SubstitutionEach word and shell variable on a command line is checked to see whether it begins with an unquoted ~. If it does, the rest of the word or variable up to a / is considered a login name and is looked up in a system file, typically /etc/passwd. If that user exists, his home directory replaces the ~ and his login name. If that user doesn't exist, the text is unchanged. A ~ by itself or followed by a / is replaced by the HOME variable. Arithmetic ExpressionsGeneral Format: $((expression)) The shell evaluates the integer arithmetic expression. expression can contain constants, shell variables (which don't have to be preceded by dollar signs), and operators. The operators, in order of decreasing precedence, are
| logical AND | |||||||||||||||||||||||||||||||||
|| | logical OR | |||||||||||||||||||||||||||||||||
expr1 ? expr2 : expr3 | conditional operator | |||||||||||||||||||||||||||||||||
=, *=, /=, %= | assignment | |||||||||||||||||||||||||||||||||
+=, <<=, >>=, &=, | ||||||||||||||||||||||||||||||||||
^=, |= |
Parentheses may be used to override operator precedence.
The exit status is zero (true) if the last expression is nonzero and one (false) if the last expression is zero.
The C operators sizeof, ++, and -- may be available in your shell implementation but are not required by the standard.
Examples
y=$((22 * 33))
z=$((y * y / (y - 1)))
|
No comments:
Post a Comment