Bash: let: evaluate arithmetic expressions

nick3499
1 min readFeb 19, 2017

--

num1=2; demonstrates how a numerical value can be assigned to a variable. let evaluates arithmetic expressions. The sum of both variables is assigned to a new variable named result.

#!/bin/bashnum1=2;
num2=3;
let result=num1+num2
echo $result

The script above prints:

5

--

--

nick3499
nick3499

Written by nick3499

coder of JavaScript and Python

No responses yet