#!/bin/sh
offWorkTime="19:00:00"
offWorkHour=${offWorkTime::}
offWorkMinute=${offWorkTime::}
offWorkSecond=${offWorkTime::}
currentTime=`TZ='Asia/Hong_Kong' date +%H:%M:%S`
currentHour=${currentTime::}
currentMinute=${currentTime::}
currentSecond=${currentTime::}
second=$((offWorkSecond - currentSecond))
if [[ $second -lt 0 ]]
then
second=$((second + 60))
offWorkMinute=$((offWorkMinute - 1))
if [[ $offWorkMinute -lt 0 ]]
then
offWorkMinute=$((offWorkMinute + 60))
offWorkHour=$((offWorkHour - 1))
fi
fi
minute=$((offWorkMinute - currentMinute))
if [[ $minute -lt 0 ]]
then
minute=$((minute + 60))
offWorkHour=$((offWorkHour - 1))
fi
hour=$((offWorkHour - currentHour))
while true
do
second=$((second - 1))
if [[ $second -lt 0 ]]
then
second=$((second + 60))
minute=$((minute - 1))
if [[ $minute -lt 0 ]]
then
minute=$((minute + 60))
hour=$((hour - 1))
fi
fi
if [[ $second -lt 10 ]]
then
secondStr="0$second"
else
secondStr="$second"
fi
if [[ $minute -lt 10 ]]
then
minuteStr="0$minute"
else
minuteStr="$minute"
fi
if [[ $hour -lt 10 ]]
then
hourStr="0$hour"
else
hourStr="$hour"
fi
tput cup 0 0
tput civis
echo $(tput setaf 1; tput setab 6; tput bold)"offworkTime: $hourStr:$minuteStr:$secondStr"$(tput sgr0)
if [[ $hour -eq 0 && $minute -eq 0 && $second -eq 0 ]]
then
break
fi
sleep 1s
done
手机扫一扫
移动阅读更方便
你可能感兴趣的文章