Computer Science, asked by sowmiyalakshmin, 7 months ago

Script - Pattern Printing in unix

Write a shell script using for loop to print the following pattern.
1
22.
333
4444
55555​

Answers

Answered by dreamrob
2

Program:

#!/bin/sh

for i in {1..5}

do

   for j in $(seq 1 $i)

   do

       printf "$i"

   done

   printf "\n"

done

   

Output:

1

22

333

4444

55555

More Patterns:

Pattern 1:

1

12

123

1234

12345

Program:

#!/bin/sh

for i in {1..5}

do

   for j in $(seq 1 $i)

   do

       printf "$j"

   done

   printf "\n"

done

   

Pattern 2:

12345

1234

123

12

1

Program:

#!/bin/sh

for i in {5..1}

do

   for j in $(seq 1 $i)

   do

       printf "$j"

   done

   printf "\n"

done

   

Similar questions