10#!/bin/bash11SEC=1012MIN=113((NUM=MIN*60+SEC))14for(($NUM;NUM>0;NUM--))15do16((min=$NUM/60))17((sec=$NUM%60))18echo"After $min:$sec time will be end!"19sleep120done21echo"Time is end!"
(2)逻辑
#!/bin/bashSEC=10MIN=1for((;SEC>+0;SEC--))doif["$SEC"="0" -a "$MIN"="0"]thenexitelif["$SEC"="0" -a "$MIN" -ge "0"]thenecho -ne "$MIN:$SEC"sleep1echo -ne "\r"SEC=6((MIN--))elseecho -ne "$MIN:SEC"sleep1echo -ne "\r"fidone