Tips for using tput in shell scripts (Tput control cursor position)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.