Special Characters#
What makes a character special? If it has a meaning beyond its literal meaning, a meta-meaning, then we refer to it as a special character. Along with commands and keywords, special characters are building blocks of Bash scripts.
Special Shell Variables#
Operator Precedence#
In a script, operations execute in order of precedence: the higher precedence operations execute before the lower precedence ones.
| Operator | Meaning | Comments |
|---|---|---|
| HIGHEST PRECEDENCE | ||
| var++ var– | post-increment, post-decrement | C-style operators |
| ++var –var | pre-increment, pre-decrement | |
| ! ~ | negation | logical / bitwise, inverts sense of following operator |
| ** | exponentiation | arithmetic operation |
| * / % | multiplication, division, modulo | arithmetic operation |
| + - | addition, subtraction | arithmetic operation |
| « » | left, right | shift bitwise |
| -z -n | unary comparison | string is/is-not null |
| -e -f -t -x, etc. | unary comparison | file-test |
| < -lt > -gt <= -le >= -ge | compound comparison | string and integer |
| -nt -ot -ef | compound comparison | file-test |
| == -eq != -ne | equality / inequality | test operators, string and integer |
| & | AND | bitwise |
| ^ | XOR | exclusive OR, bitwise |
| | | OR | bitwise |
| && -a | AND | logical, compound comparison |
| | -o | OR | logical, compound comparison |
| ?: | trinary operator | C-style |
| = | assignment | (do not confuse with equality test) |
| *= /= %= += -= «= »= &= | combination assignment | times-equal, divide-equal, |
| , | comma | links a sequence of operations |
| LOWEST PRECEDENCE |
TEST Operators: Binary Comparison#
|Greater than = |Greater than or equal to < |Less than <= |Less than or equal to
