This is an old revision of the document!

The let builtin




The let builtin command evaluates the arithmetic expression <EXPRESSION> and returns the exit codes

  • 0 (TRUE) when <EXPRESSION> evaluated to not 0 (arithmetic "true")
  • 1 (FALSE) when <EXPRESSION> evaluated to 0 (arithmetic "false")

For this return code mapping, please see this section.

The form (note the quoting!)


is identical to the arithmetic evaluation compound command (except the exit code)


This way should be preferred.


Portability considerations

The let command is not specified by POSIX®. The standard equivalent is:

[ "$(( <EXPRESSION> ))" -ne 0 ]

The quotes around the arithmetic expansion are only necessary with bash and AT&T versions of ksh, other standard shells such as ash, pdksh or zsh derivatives don't have that bug/misfeature.

See also


joshua toyota, 2011/01/13 09:33

I believe the internal links to "arithmetic expansion" should be directed here:

Instead of:

Just an fyi...

Jan Schampera, 2011/01/13 17:40

Of course, my bad...


Enter your comment. Wiki syntax is allowed: