Pyramid

Pyramid

How to Use this script

Step-1  Create a file name it  'pyramid.sh'.

Step-2  Copy Complete below written script in the file created and save it.

Step-3  Set executable permission by runing following command ( [ root @ server1~ ]#  chmod   a+x   pyramid.sh ) .

Step-4  Run script like  ./pyramid.sh  which will draw chess board on terminal.

#!/bin/bash
# Author : LEOxian
# License: GPLv2
# Description: Pyramid
# Date : 20-March-2012
 
 
MAX_NO=9
for (( i=1; i<=$MAX_NO; i++ ))
do
rowno=$(expr $i  + $MAX_NO)
colno=$(expr 15 + $i - $MAX_NO)
tput cup  $rowno $colno
valno=$(expr  $MAX_NO  -  $i )
for (( j=1; j<=$valno;  j++ ))
do
echo -n " *" 
done
echo ""
done
 
echo -e "\n\tI hope you like it(?)\n"

 

Cheers!!