Read 'n' and generate a pattern given below(number increment from left to right)

 #!/bin/bash






<<doc

Description  : Read 'n' and generate a pattern given below(number increment from left to right)

Sample input : Enter the number: 4

Sample Output:1

              1 2

              1 2 3 

              1 2 3 4 

doc


read -p "Enter the number :" number  #Number of element

for row in `seq $number`             #number of row to be printed

do

    for col in `seq $row`          #Number of column to be printed    

    do

        echo -n "$col "          #Required value for pattern

    

    done

  echo

done

Comments

Popular posts from this blog

Write a script for arithmetic calculator using command line arguments

Count the number of users with user IDs between given range.

Write a script to print system information using commands