Session and utilities

The expr command

Evaluates simple arithmetic and logical expressions from the command line.

Syntax

expr 2 + 3

Copy-ready examples

$ expr 2 + 3Addition
$ expr 10 - 4Subtraction

You 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.

Related commands

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