How to use shell script functions to control color, positioning, and centered display
This article mainly shows you "how to use shell script function to control color, positioning, center display", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use shell script function to control color, positioning, center display" this article.
1. Control color
Code:
#! / bin/sh
Function colour ()
{
Case $1 in
Black_green)
Echo-e'\ 033 [40 * 32m'
Black_yellow)
Echo-e'\ 033 [40 * 33m'
Black_white)
Echo-e'\ 033 [40 * 37m'
Black_cyan)
Echo-e'\ 033 [40 * 36m'
Black_red)
Echo-e'\ 033 [40 * 31m'
Colour_default)
Echo-e'\ 033 [0m'
Esac
}
Second, positioning
Code:
#! / bin/sh
Function xy ()
{
_ Renewal 1
_ Category 2
_ TEXT=$3
Tput cup $_ R $_ C
Echo-n $_ TEXT
}
Third, centered display
Code:
#! / bin/sh
Function center ()
{
_ STR=$1
_ ROW=$2
LEN= `echo $_ STR | wc-c`
COLS= `tput cols`
HOLD_COL= `expr $COLS-$LEN`
NEW_COL= `expr $HOLD_COL / 2`
Tput cup $_ ROW $NEW_COL
Echo-n $_ STR
}
The above is all the contents of the article "how to use shell script functions to control color, position, and center display". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!