nick34992
2/19/2017 - 4:25 PM

Bash: let: evaluate arithmetic

Bash: let: evaluate arithmetic

#!/bin/bash

num1=2;
num2=3;

let result1=num1+num2 # addition
echo $result1
let result2=num1+=1 # increment
echo $result2
let result3=num1-=1 # decrement
echo $result3

# 5
# 3
# 2