Help with Using "while" loop to output series of numbers

Trying to use "while" loop command to create a series of numbers that looks like the following:
0 .
1 0 .
2 1 0 .
3 2 1 0 .
4 3 2 1 0 .
5 4 3 2 1 0 .
6 5 4 3 2 1 0 .
7 6 5 4 3 2 1 0 .
8 7 6 5 4 3 2 1 0 .
9 8 7 6 5 4 3 2 1 0 .

I am very new to shell scripting and any help would be greatly appreciated.
Thanks

Have you tried any pseudocode yet? If not, please try and then we can suggest the unix command to be used for each of the steps.

post your code what you have tried. its simple. u can use two while loops.. try it u will get it.. if not then post the code, someone will fix it for sure..

#!/bin/bash
i="0"
p="."
while [ $i -lt 10 ]
        do
        p="$i $p"
        echo $p
        ((i++))
done
1 Like

another way:

i=0
while [ $i -le 9 ]; do
        j=$i
        while [ $j -ge 0 ]; do
                echo -n "$j "
                (( j-- ));
        done
        echo "."
        ((i++))
done
1 Like

Just for test: awk

awk 'BEGIN {a="."; for (i=0;i<=9;i++) {a=i" "a;print a}}'

Without explicit looping:

seq 0 9 | sed '1s/$/ ./; 1!G; y/\n/ /; h'

Regards,
Alister

1 Like

lazy math-less way:

for N in 0 1 2 3 4 5 6 7 8 9
do
        STR="$STR $N"
        echo "$STR ."
done