Sunday, January 2, 2011

Happy New Year Shell Script


Wish You a Happy New Year To All My Friends




If you don't know shell color codes, read bellow article first.
How to colorize shell scripts

#!/bin/bash
# SCRIPT: happynewyear.sh
# PURPOSE: Prints Happy new year 2011 on screen.
# \\\\ ////
# \\ - - //
# @ @
# ---oOOo-( )-oOOo---
#
##############################################################################
# Arguments Checking #
##############################################################################

if [ $# -eq 1 ]
then
fname=$1
else
echo "Invalid Arguments"
echo "Usage: happynewyear.sh filename"
exit
fi

##############################################################################
# Main Starts #
##############################################################################

clear
i=0

while read line
do

if [ $i -lt 8 ] ; then
COLOR1="\e[1;31;40m" ; COLOR2="\e[0m" # Dark Red
elif [ $i -gt 8 -a $i -lt 17 ] ; then
COLOR1="\e[1;37;40m" ; COLOR2="\e[0m" # White
elif [ $i -gt 17 -a $i -lt 26 ] ; then
COLOR1="\e[1;32;40;5m" ; COLOR2="\e[0m" # Dark Green with blinking
fi # effect


newline=`echo "$line" | tr '69' ' @' `
printf "$COLOR1$newline $COLOR2" # you can also use echo -e "...."
let i++
sleep 0.1


done < $fname

read # Waits for enter



Copy bellow data and save it as newyear.txt

6666666666996666699666666666966666666669999999996699999999966996666669966666666
6666666666996666699666666669996666666669999999996699999999966699666699666666666
6666666666996666699666666699669966666669966666996699666669966669966996666666666
6666666666999999999666666996666996666669999999996699999999966666999966666666666
6666666666999999999666669999999999666669999999996699999999966666699666666666666
6666666666996666699666699999999999966669966666666699666666666666699666666666666
6666666666996666699666996666666666996669966666666699666666666666699666666666666
6666666666996666699669966666666666699669966666666699666666666666699666666666666
6666666666666666666666666666666666666666666666666666666666666666666666666666666
9966666996699999999669966666996666699666666996999999996666666696666666699999999
9996666996699999999669966666996666669966669966999999996666666999666666699999999
9999666996699666666669966666996666666996699666996666666666669969966666699666699
9969966996699999999669966966996666666699996666999999996666699666996666699999999
9966996996699999999669969996996666666669966666999999996666999999999666699999999
9966699996699666666669999699996666666669966666996666666669999999999966699699666
9966669996699999999669996669996666666669966666999999996699666666666996699669966
9966666996699999999669966666996666666669966666999999996996666666666699699666699
6666666666666666666666666666666666666666666666666666666666666666666666666666666
6666666666666666666666699999999666999699999666999666699966666666666666666666666
6666666666666666666666699999999666996666699666699666669966666666666666666666666
6666666666666666666666666666996666999666699666699666669966666666666666666666666
6666666666666666666666666669966666996696699666699666669966666666666666666666666
6666666666666666666666666699666666996669699666699666669966666666666666666666666
6666666666666666666666669966666666996666999666699666669966666666666666666666666
6666666666666666666666699999999666996666699666699666669966666666666666666666666
6666666666666666666666699999999666999699999666999966699996666666666666666666666



For blinking effect run this script in console, not in terminal.

OUTPUT:
$ sh happynewyear.sh newyear.txt


1 comments: