Operators
Operators can be one of the following types.
Assignment operators
Operator |
Description |
|
Assign value. |
|
Reassign after addition/subtraction. |
|
Reassign after multiplication/division/remainder. |
|
Reassign after bitwise AND/XOR/OR. |
|
Increment. |
|
Decrement. |
Arithmetic operators
Operator |
Description |
|
Multiplication; integer division; modulus (remainder). |
|
Addition; subtraction. |
Bitwise and logical operators
Operator |
Description |
~ |
Binary inversion (one’s complement). |
|
Logical negation. |
|
Bitwise left shift; bitwise right shift. |
|
Bitwise AND. |
|
Bitwise exclusive OR. |
|
Bitwise OR. |
|
Logical AND (short-circuit). |
|
Logical OR (short-circuit). |
|
Return 1 if
command is successful, 0 otherwise.
Note that this is the opposite of
command ’s normal return code. The
|
Comparison operators
Operator |
Description |
|
Equality; inequality. |
|
Less than or equal to; greater than or equal to. |
|
Less than; greater than. |
|
String on left matches a
filename pattern on right containing |
|
String on left does not match a
filename pattern on right containing |
File inquiry operators
Command substitution and filename expansion are performed on
file before the test is performed. Operators
can be combined (e.g., -ef
). The following is a
list of the valid file inquiry operators.
Operator |
Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.