我正在尝试创建倒计时 - 很可能是艰难的方式。我有这样的设置:
#! /bin/bash
#When to execute command
execute=$(date +"%T" -d "22:30:00")
#Current time
time=$(date +"%T")
#Subtract one from the other.... the below is line 11
math=$(("$execute"-"$time"))
#Repeat until time is 22:30:00
until [ "$math" == "00:00:00" ]; do
echo "Countdown is stopping in $math"
sleep 1
clear
done
问题是......它不起作用。这是终端中的输出:
/path/to/file/test.sh: line 11: 22:30:00-16:39:22: syntax error in expression (error token is “:30:00-16:39:22”)
Countdown is stopping in
首先,错误信息,有什么问题?
其次,“倒计时正在停止”消息应该有倒计时将停止的小时、分钟和秒。为什么不呢?请记住,我不是专业人士。