用Shell实现一个倒计时

#!/bin/bash

echo -n Count:
tput sc

count=0
while true;
do
        if [ $count -lt 40 ];then
                let count++;
                sleep 1;
                tput rc
                tput ed
                echo -n $count;
        else
                exit 0;
        fi
done


使用Shell实现一个倒计时,

 

其中,tput sc 是存储光标位置,

            tput rc 是恢复光标位置

           tput   ed  是清除光标位置,到行尾的内容。

 

能够实现,清除以前输出的内容,显示现在的内容,这个值得学习。

 

 

你可能感兴趣的:(用Shell实现一个倒计时)