My code is :
#!/bin/bash
while true; do
COUNTER=$((COUNTER +1))
echo $COUNTER
if (($COUNTER%3 == 0)); then
echo "Counter now is 3"
sleep 2
fi
if (($COUNTER%6 == 0)); then
echo "Counter now is 6"
sleep 2
fi
if (($COUNTER%9 == 0)); then
echo "Counter now is 9"
sleep 2
fi
if (($COUNTER%12 == 0)); then
echo "Counter now is 12"
sleep 2
fi
if (($COUNTER%15 == 0)); then
echo "Counter now is 15"
sleep 2
exit
fi
done
and my output is :
./test2.sh
1
2
3
Counter now is 3
4
5
6
Counter now is 3
Counter now is 6
7
8
9
Counter now is 3
Counter now is 9
10
11
12
Counter now is 3
Counter now is 6
Counter now is 12
13
14
15
Counter now is 3
Counter now is 15
Why is it showing, every time, Counter now is 3
or sometime show more on echo
. I don't want it to show additional on echo
6
,9
,12
and15
are also multiples of3
continue
statement at the bottom of each test