Knowledge Points:
1) Sleep: Used to implement the delay function in the script, sleep N, delay n seconds
2) Tput: Change the terminal display characteristics, common usage is as follows:
Tput lines: Displays the number of lines of the terminal
Tput cols: Displays the number of columns of the terminal
Tput Cup Line_number collum_number: Position cursor to Line_number row, collum_number column location
Tput setb N: where n is 0-7 digits, set the terminal's background color
Tput setf N: where n is 0-7 digits, sets the foreground color of the terminal, that is, the color of the font
Tput SC: Where to save the cursor
Tput RC: Restores the cursor to the last saved position
Tput Ed: Clears everything from the cursor position to the end of the screen
Tput Smul: Set underline
Tput Rmul: Remove underline
Tput Bold: Set Text style to bold
================== Gorgeous split-line ====================
The following script is used to implement the function of counter, display the number of seconds in the terminal, count by seconds, count to 10 seconds
==================================================
#!/bin/bash
# Script Name:sleep.sh
# DATE:12/16 2016
# Author:david
# Mail: [email protected]
# 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
This article is from the "Davidlee's Linux Road" blog, so be sure to keep this source http://davidlinux.blog.51cto.com/5965954/1883418
Tips for using tput in shell scripts (Tput control cursor position)