Increment variable value by 1 ( shell programming)
You can use an arithmetic expansion like so:
i=$((i+1))
or declare i
as an integer variable and use the +=
operator for incrementing its value.
declare -i i=0
i+=1
or use the ((
construct.
((i++))
The way to use expr:
i=0
i=`expr $i + 1`
the way to use i++
((i++)); echo $i;
Tested in gnu bash