方案一:
#!/bin/bash
MIN_Value=`echo $1 | awk -F : '{print $1}'`
SEC_Value=`echo $1 | awk -F : '{print $2}'`
All_Sec=$[$MIN_Value*60+$SEC_Value]
for ((;All_Sec>=0;All_Sec--))
do
MIN=$[All_Sec/60]
SEC=$[All_Sec%60]
echo -ne "\rAfter $MIN:$SEC is end!!"
sleep 1
Done
执行:sh daojishi.sh 1:20
方案二:方法二不同于方法一的是通过判断进行,可以更改一分钟里面的秒数
#!/bin/bash
MIN_Value=`echo $1 | awk -F : '{print $1}'`
SEC_Value=`echo $1 | awk -F : '{print $2}'`
for ((;SEC_Value>=0;SEC_Value--))
do
[ "SEC_Value" = "0" -a "$MIN_Value" = "0" ]&& exit
[ "SEC_Value" = "0" -a "$MIN_Value" -gt "0" ]&&{
echo -ne "\r$MIN_Value:$All_Sec"
((MIN_Value--))
SEC_Value=59
sleep 1
}
echo -ne "\r$MIN_Value:$SEC_Value"
sleep 1
done