Operators
bash uses arithmetic operators from the C programming language; the following list is in decreasing order of precedence. Use parentheses to override precedence.
|
Operator |
Meaning |
|
|
Unary minus |
|
|
Logical negation; binary inversion (one’s complement) |
|
|
Multiplication; division; modulus (remainder) |
|
|
Addition; subtraction |
|
|
Bitwise left shift; bitwise right shift |
|
|
Less than or equal to; greater than or equal to |
|
|
Less than; greater than |
|
|
Equality; inequality (both evaluated left to right) |
|
|
Bitwise AND |
|
|
Bitwise exclusive OR |
|
|
Bitwise OR |
|
|
Logical AND |
|
|
Logical OR |
|
|
Assign value |
|
|
Reassign after addition/subtraction |
|
|
Reassign after multiplication/division/remainder |
|
|
Reassign after bitwise AND/XOR/OR |
|
|
Reassign after bitwise shift left/right |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access