Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux let command

Linux let command

Linux Command Reference Linux Command Reference

Command: let

The let command is a tool in BASH used for calculations; it executes one or more expressions, and variables do not need a $ prefix in variable calculations. If an expression contains spaces or other special characters, it must be quoted.

Syntax format



let arg [arg ...]

Parameter Description:

arg: the expression to execute

Example:

Increment operation:let no++

Decrement operation:let no--

Short form let no+=10, let no-=20, equivalent respectively to let no=no+10, let no=no-20.

The following example evaluates the two expressions a and b and outputs the results:



#!/bin/bash



let a=5+4

let b=9-3 

echo $a $b

The example above produces:



9 6

Linux Command Reference Linux Command Reference