Click to See Complete Forum and Search --> : Help


shellme
05-27-2005, 01:42 PM
This script i worte doesnt work right..

it is supposed to tell how many days till a certain date.. when you type in a date 2 days from now it says 2.. but if you say 2 days before it say 2 also... it doesnt say 363 days! please help here is the script i wrote..

#!/bin/bash

echo "Enter your birthday as Month Day, i.e. May 19"
read birthday
now=`date +%d`
birthdayday=`date -d "$birthday" +%d`

if [ "$birthdayday" -gt "$now" ]; then
let numofday=$birthdaysec-$now
else
let numofday=$now-$birthdayday
fi
echo "Number of days until your birthday: $numofday"
exit 0

please make this work right!!

Hayl
05-27-2005, 01:48 PM
Please review or posting guidelines and repost your question with a subject that relates to the question being asked.

the posting guidelines are in sticky posts at the top of each forum,

thank you.

<closed>

(you also may want to look into using code tags around code in your posts, it makes it more readable and you will get more replies. the tags are [ code ] and [ /code ] without the extra spaces of course.)