Session and utilities
The expr command
Evaluates simple arithmetic and logical expressions from the command line.
Syntax
expr 2 + 3Copy-ready examples
$ expr 2 + 3Addition$ expr 10 - 4SubtractionYou can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- Operators must be space-separated; expr 2+3 does not work the same.
- The multiplication asterisk must be escaped: expr 3 \* 4.
FAQ
Is it still used?
Less: today $(( )) or bc is preferred, but it appears in many old scripts.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course