SUPPORT THE SITE WITH A CLICK

Subscribe Rss:

SUPPORT THE SITE WITH A CLICK

Wednesday, January 26, 2011

My first shell script to fetch the dates

I was with linux for the past 4.5 years, but i didn't try anything with shell scripts.Now i had a small work to deal with that.My requirement was so simple, want to fetch dates from a text file and compare with the current date.If it matches then i should do some job or display some text.If not then i should exit from the text.
#!/bin/bash
# Script to fetch the date and compare with the current date
clear
for hdate in $(cat hol.txt)
do
if [ $hdate -eq  $(date +"%Y%m%d") ] ; then
echo "You have choosen the current date"
exit 0
else
echo "Nothing"
fi
done

No comments :

Post a Comment