Loop n times:
while [ $((i=${i:=0}+1)) -le "$n" ]; do
echo line $i
done
Output for n=5:
line 1
line 2
line 3
line 4
line 5
Manipulating decimals:
$ i=3.14159; echo $((${i%.*}*2))
6
$ i=3.14159; echo $((${i#*.}*2))
28318
$ ispow2() { return $((!($1!=0&&($1&$1-1)==0))); }
$ i=0
$ while [ $i -lt 100 ]; do
> if ispow2 $((i=i+1)); then
> echo $i
> fi
> done
1
2
4
8
16
32
64
$1!=0 0 is not a power of 2.
($1&$1-1)==0 Unset the lowest bit. If it was the only bit...