shell script programming for  print triangle pattern using and loop  how to print a triangle pattern using shell script

shell script programming

shell script programming

#!/bin/bash
n=6
a=$n/2
for((i=1; i<=$a;i++))
do
for((k=i; k<=$n;k++))
do
echo -ne ” “;
done
for((j=1; j<=2*i-1;j++))
do
echo -ne “*”;
done
echo;
done

for((i=$a-1;i>=0;i–))
do
for((k=i; k<=$n; k++))
do
echo -ne ” “;
done
for((j=1;j<=2*i-1;j++))
do
echo -ne “*”;
done
echo;
done

 

on this shell script program 2 part will work 1 and 2nd

shell script

shell script

 

Leave a reply