一个简单的记时脚本

可以实现的功能:
输入一个提前的时间(10:10, 10点10分)
到时间自动终止

#!/bin/bash
 
read -p "Please input the time (like: `date +%H:%M`): " time
echo $time
 
while :
do
    if [ `date +%H:%M` = "$time" ]
    then
        echo "$time is up!"
        break
    else
        for ((i=0;i<5;i++))
        do
            echo -n "* "
            sleep 1
        done
        echo -ne "`date +%H:%M:%S` \n"
    fi
 
done

运行结果:

[root@localhost shell]# sh 5.sh
Please input the time (like: 00:28): 00:29
00:29
* * * * * 00:28:44
* * * * * 00:28:49
* * * * * 00:28:55
* * * * * 00:29:00
00:29 is up!