nick34992
2/19/2017 - 5:02 PM

Bash: Square Brackets: Add and Subtract Variables

Bash: Square Brackets: Add and Subtract Variables

#!/bin/bash

num1=2;
num2=3;

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