Linux let command

Linux 命令大全Linux Command Reference

Command: let

The let command is a tool used for calculations in BASH. It is used to execute one or more expressions. In variable calculations, there is no need to add $ to represent variables. If the expression contains spaces or other special characters, it must be quoted.

Syntax

let arg [arg ...]

Parameter description:

arg: the expression to be executed

Examples:

Increment operation:let no++

Decrement operation:let no--

Shorthand formslet no+=10,let no-=20, respectively equivalent tolet no=no+10,let no=no-20。

The following example calculates the two expressions a and b, and outputs the result:

#!/bin/bash

let a=5+4
let b=9-3 
echo $a $b

The execution result of the above example is:

9 6

Linux 命令大全Linux Command Reference

Other Extensions