The let builtin

let <EXPRESSION>

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”)

The form (note the quoting!)

let "<EXPRESSION>"

is identical to the arithmetic evaluation compound command

(( <EXPRESSION> ))

The standard equivalent is:

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

(the quotes around 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

commands/builtin/let.txt · Last modified: 2009/02/24 07:25 (external edit)
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0