Plz tel me how to print the following pattern using shell script??
*
***
*****
*******
*****
***
*
and
*
*********
*
Plz tel me how to print the following pattern using shell script??
*
***
*****
*******
*****
***
*
and
*
*********
*
Use following :
echo \*
i.e :
echo \*
echo \***
echo \****
echo \******
echo \****
echo \***
echo \*
one (bash) way:
# for x in 1 3 5 7 5 3 1; do printf "%.$((3-$x/2))d" 0|tr "0" " ";printf "%.${x}d\n" 0|tr "0" "*"; done
*
***
*****
*******
*****
***
*
Diamond long version :rolleyes:
perl -e 'printf("%s%s\n%s%s\n%s%s\n%s\n%s%s\n%s%s\n%s%s\n"," "x3,"*"x1," "x2,"*"x3," ","*"x5,"*"x7," ","*"x5," "x2,"*"x3," "x3,"*"x1)'
Diamond short version
perl -e 'for (3,2,1,0,1,2,3) {print " "x$_."*"x(7-2*$_)."\n";}'
Division sign:
perl -e 'for (4,0,4) {print " "x$_."*"x(9-2*$_)."\n";}'
cat<<EOF
*
***
*****
*******
*****
***
*
EOF