LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   another script :) (https://www.linuxquestions.org/questions/linux-newbie-8/another-script-266230/)

Alexander.s 12-14-2004 07:03 AM

another script :)
 
im sitting here stuck with an ideah but i cant figure out how to do it

i want the script to tell me how much time is left until i have to go to my kungfu practice
and thats 16:20 :D

i want it to say:
You have only 1 hour and fifteen minutes left.
come on!

and it should be accurate to the actual clock ofcourse :)

i did something like
#!/bin/bash
for i in `date`; do
while [ $i -ge 15:30 ] && [ $i -le 16:20 ]; do
echo you have only 50 minutes left! come on!
done

but i dont think that will work so i need some help.
should i use cut on date? how?


thanks!

homey 12-14-2004 10:29 AM

Maybe this little diddy will get you started.

Code:

#!/bin/bash

hour=`date +%H`
min=`date +%M`
hour_max=16
min_max=20
echo "The time is $hour:$min"
    if [ $hour -lt 12 ];then
echo "Good Morning"
    elif [ $hour -ge 12 -a $hour -le 16 ]; then
echo "Good Afternoon"
            if [ $hour -le 16 -a $min -lt $min_max ]; then
            a=$(($hour_max - $hour))
        b=$(($min_max - $min))
        echo "You have $a hours and $b minutes to get to kungfu practice"
        else
        echo "Maybe you can get the next kungfu practice"
        fi
    else
echo "Good Night"
    fi



All times are GMT -5. The time now is 12:18 PM.