Up Next Previous

## Logical, arithmetical and comparison operators

These operators are similar to those of C and have the same precedence. They include

|| && | ^ & == != =~ !~ <= >=
< > << >> + - * / % ! ~ ( )

Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' `>=' `<' and `>', `<<' and `>>', `+' and `-', `*' `/' and `%' being, in groups, at the same level. The `==' `!=' `=~' and `!~' operators compare their arguments as strings; all others operate on numbers. The operators `=~' and `!~' are like `==' and `!=' except that the right hand side is a glob-pattern (see Filename substitution) against which the left hand operand is matched. This reduces the need for use of the switch builtin command in shell scripts when all that is really needed is pattern matching.

Null or missing arguments are considered `0'. The results of all expressions are strings, which represent decimal numbers. It is important to note that no two components of an expression can appear in the same word; except when adjacent to components of expressions which are syntactically significant to the parser (`&' `|' `<' `>' `(' `)') they should be surrounded by spaces.

Up Next Previous