Tuesday, April 19, 2011

To add two integers in Shell Script

Adding two numbers are not as easy as i=$i+1 in shell script. It is done using different ways. Here is one example :-

#!/bin/sh
i=1
while [ $i -lt 3 ]
do
echo "test"
i=$(($i+1))
echo $i
done