SYNOPSIS
let expression...
DESCRIPTION
In the KornShell let evaluates each arithmetic expression from left to right with normal algebraic precedence (multiplication before addition, for example). let uses long integer arithmetic with no checks for overflow. No output is generated; the exit status is 0 if the last expression has a non-zero value and 1 otherwise.
If you issue the command
set -o korn
the line
let "expression"
can also be expressed as
((expression))
This form avoids quoting and enhances readability.
The portable way to write these commands is to use the POSIX command:
: $((expression))
Expressions consist of named variables, numeric constants and operators.
See Arithmetic Substitution in sh for syntax of expressions.
EXAMPLE
The commands
let a=7 'b=4*2' c=b+1 echo $a $b $c
produce
7 8 9
DIAGNOSTICS
Possible exit status values are:
- 0
-
The last argument evaluated to a non-zero value.
- 1
-
The last argument evaluated to a zero value, or the expression contained a syntax error or tried to divide by zero.
PORTABILITY
Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022. Windows Server 2025.
let is built into the KornShell on UNIX systems and is not a Bourne Shell command.
NOTE
This command is built into the MKS KornShell.
AVAILABILITY
PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC Windchill Requirements and Validation
SEE ALSO
Using the MKS KornShell
PTC MKS Toolkit 10.5 Documentation Build 40.