Results 1 to 3 of 3
Hello all! I am new to linux and I am trying to learn bash scripts. I would like to be able to ask the user for their birthday and then ...
- 11-14-2008 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 1
Compare date to variables in bash
Hello all! I am new to linux and I am trying to learn bash scripts. I would like to be able to ask the user for their birthday and then compare that to the system date. I would like it to display a message if it's their birthday, and a different one if it's not. It doesn't have to be this exactly, it's just something I was trying, so something similar would work, too. Basically, I just wanna compare user inputs to the date.
Also, is there a way to insert a pause between messages? ie, echo 1, [pause 1 second], echo 2, etc.
In case it matters, I'm running SLES 10. Thanks in advance!
- 11-14-2008 #2Linux Newbie
- Join Date
- May 2007
- Posts
- 106
- 06-04-2009 #3Just Joined!
- Join Date
- Apr 2009
- Posts
- 3
sol a bit late maybe will be useful for someone else
#------------------
b=`date +%D`
echo -e "Enter your birthday (format mm/dd/yy 06/04/09 ) \c"
read a
if [ "$a" = "$b" ]
then
# do whatever you like
echo "happy birthday"
else
#code block
echo "Better wait for a few more days "
fi



