shell脚本实现秒表功能

#!/bin/bash
M1=0
M2=0
S1=0
S2=0
while true
do
        NUM=$(echo "${M1}${M2}:$S1$S2")
        echo -ne "\033[32m $NUM\b\r\033[0m"
        (( S2++ ))
        if [ $S2 -ge 10 ];then
                (( S1++ ))
                S2=0
        fi
        if [ $S1 -ge 6 ];then
                (( M2++ ))
                S1=0
        fi
        if [ $M2 -ge 10 ];then
                (( M1++ ))
                M2=0
        fi
        sleep 1
done

posted @ 2020-01-15 11:08  IMSCZ  阅读(590)  评论(0编辑  收藏  举报