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