Session and utilities

The let command

Performs arithmetic and stores the result in variables, right on the command line.

Syntax

let variable=expresión

Copy-ready examples

$ let x=2+3 && echo $xCompute and use the result

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • If the expression has spaces you must quote it.

Related commands

FAQ

How does it differ from $(( ))?

let stores the result in a variable; $(( )) returns the value to use directly.

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