知识点:

1)sleep : 用以实现脚本中延时功能,sleep n,延时 n 秒

2)tput : 改变终端显示特性,常见用法如下:

tput lines : 显示终端的行数

tput cols : 显示终端的列数

tput cup line_number collum_number : 定位光标到 line_number 行,collum_number 列的位置

tput setb n : 其中 n 为 0-7 的数字,设置终端的背景颜色

tput setf n : 其中 n 为 0-7 的数字,设置终端的前景色,即字体的颜色

tput sc : 保存光标的位置

tput rc : 恢复光标到上一次保存的位置

tput ed : 清空光标所在位置到屏幕结尾的所有内容

tput smul : 设置下划线

tput rmul : 移除下划线

tput bold : 设置文本样式为粗体


==================华丽的分割线====================

以下脚本用以实现计数器的功能,在终端显示秒数,按秒计数,计数到10 秒

==================================================


#!/bin/bash

# Script name: sleep.sh

# Date: 12/16 2016

# Author: david

# mail: 1530654058@qq.com

# Version: 1.0

# Description: used for sleep some time when execute the commands


echo -n "Count:" 

tput sc

RETVAL=0

count=0

while true

do

    if [ $count -lt 10 ]

    then

        let count++

        sleep 1

        tput rc

        tput ed

        echo -n $count

    else

        echo

        exit $RETVAL

    fi

done