I want to print the numbers in the following pattern using WHILE loop.
0
01
012
0123
.....
......
0123456789
My Try:
#!/bin/sh
a=0
b=0
while [ $a -le 10 ]
do
while [ $b -le $a ]
do
echo -n "$b"
b=`expr $b + 1`
done
echo
a=`expr $a + 1`
done
Getting output:
0
1
2
3
4
5
6
7
8
9
10
bvalue which is incremented in each iteration? In other words, have you thought about the algorithm?012). Then you should append it the value ofband print it and increase the counter.whileloop? What shell are you using?expris a non-standard, old-fashioned way of doing arithmetic in the shell.bash, not any otherUNIX shellas you have tagged this question?