mardi 6 avril 2021

Unix date program, nested if statement about what time it is now and echo's a line depending on the time

I have this code that is supposed to see whether it's the weekend or not and if it is not the weekend, then it will print a certain line. However, I am getting an error with the second if statement. here is my code

#!/bin/sh
# A daily reminder service
set `date`
echo "Remember for today:"
if [ $1 == "Sat" ] | [ $1 == 'Sun' ]
then
    echo it is the weekend  
else
    if [ "5:55:00" < "$4" < "6:05:59" ] 
    then 
        echo get up
    elif [ "6:55:00" < "$4" < "7:05:59" ] 
    then
        echo have breakfast
    elif [ "7:55:00" < "$4" < "8:05:59" ] 
    then
        echo start the first class
    elif [ "21:55:00" < "$4" < "22:05:59" ] 
    then
        echo time to do homework
    fi
fi

My error looks like this

[cpm1051@srvlp-dpt-cs01 labfifteen]$ ./dailyReminder
Remember for today:
./dailyReminder: line 9: 10:29:33: No such file or directory
./dailyReminder: line 12: 10:29:33: No such file or directory
./dailyReminder: line 15: 10:29:33: No such file or directory
./dailyReminder: line 18: 10:29:33: No such file or directory

I am not sure what file it's looking for? it already captured the date. What am I doing wrong?

Any help will be greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire