Get the App
SLTechnology News&Howtos  ›  Network Security  › 

The script assistant's echo command displays words with the specified color!

Shulou Source: shulou.com Published: 2022-06-01 04:34:47 09月29日 Update

Objective:

When the script is used, if the output is colored, you can determine what went wrong with the script. The echo parameter, which indicates the font with color.

Echo-help or man echo

Echo display with color, you need to use the parameter-e

The format is as follows:

Echo-e "\ 033 [word background color; text color m string\ 033 [0m"

For example:

Echo-e "\ 033 [41th 37m TonyZhang\ 033 [0m"

The position of 41 represents the background color, and the position of 37 represents the color of the word.

Tip:

1. Symbol English "

2. There is an m after the text color, so don't ignore it.

3. There can be no spaces before and after the string, and if so, the output also has spaces.

~

Eg:

Echo-e "\ 033 [34m blue word\ 033 [0m"

Echo-e "\ 033 [35m purple word\ 033 [0m"

Echo-e "\ 033 [36m Sky Blue character\ 033 [0m"

Echo-e "\ 033 [37m White word\ 033 [0m"

Echo-e "\ 033 [30m black words\ 033 [0m"

Echo-e "\ 033 [31m red word\ 033 [0m"

Echo-e "\ 033 [32m green word\ 033 [0m"

Echo-e "\ 033 [33m × × × words\ 033 [0m"

Add the background color:

Echo-e "\ 033 [44th 37m Blue background White characters\ 033 [0m"

Echo-e "\ 033 [45th 37m purple background white characters\ 033 [0m"

Echo-e "\ 033 [46th 37m Sky Blue background White characters\ 033 [0m"

Echo-e "\ 033 [47umbent 30m black character on white background\ 033 [0m"

Echo-e "\ 033 [40 Ten 37m black background white characters\ 033 [0m"

Echo-e "\ 033 [41bot 37m red background white character\ 033 [0m"

Echo-e "\ 033 [42bot 37m White characters on green background\ 033 [0m"

Echo-e "\ 033 [43bot 37m Yellow background White character\ 033 [0m"

Other uses:

\ 33 [4m underline

\ 33 [5m flicker

\ 33 [0m turn off all properties

\ 33 [1m set high brightness

\ 33 [move the nC cursor to the right n lines

\ 33 [nD cursor move left n lines

\ 33 [ytrexh sets the cursor position

\ 33 [2J clear screen

\ 33 [K clear the contents from the cursor to the end of the line

\ 33 [s Save cursor location

\ 33 [u restore cursor position

\ 33 [? 25l hide the cursor

\ 33 [? 25h display cursor

\ 33 [7m reverse display

\ 33 [8m blanking

\ 33 [30m--\ 33 [37m set foreground color

\ 33 [40m--\ 33 [47m set background color

\ 33 [nA cursor up n lines

\ 33 [nB cursor down n lines

~

Tags: Cursor color white word position script representative parameter character string background text background output underline brightness content font attribute time scenery Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MariaDB vpn Shulou Technology Linux