# expr

Expr is a command in the UNIX operating system and its derivatives, which evaluates an expression and outputs the result. expr processed expressions with integer values or character strings as well as regular expressions.

The command is essentially used in shell scripts and for example the bash already integrated in a modern Unix shells (built in command). Most expressions that can be put together with expr, modern Unix shells can also already syntax constructs, as they are also present in programming languages , evaluate yourself.

Expr is a part of the Single Unix Specification. The GNU implementation is part of the GNU core utilities.

## Available operands

All expressions are generally subject to the rules of propositional logic, and it can be used include the following operands:

- For integers: addition, subtraction, multiplication, division and modulus
- For strings: Regular expressions evaluate to find certain characters in a string, determine length
- For Both: comparisons ( equal, not equal, less than, greater than, etc. )
- In addition, Boolean expressions are used with the logic operators, and or and.

## Example

The following expression returns the result " 1":

$ Expr length " abcdef ", " <" 5 "|" 15-4 " > " 8 In general, the expression is divided into a left and right part of the disjunction, both of which are evaluated separately before the disjunction is used:

- The length of the character string " ABCDEF " is 6, that is greater than 5, the left part of the expression thus obtained 0
- Since, however, 15-4 11 results and this number is greater than 8, gives the right part true, so 1

Now the final disjunction can be applied, from 0 | 1, the result is then obtained 1