Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Settings of display colors for shell scripts

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Format: echo "/ 033 [word background color; font color m string / 033 [control code"

If only the font color is displayed, the code point 0m can be fixed.

Format: echo "/ 033 [word background color; font color m string / 033 [0m"

Note:

1. The relationship between the background color and the text color is in English.

2. There is an m after the text color.

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

Word background color range: 40-49

40: black

41: crimson

42: green

43: × ×

44: blue

45: purple

46: dark green

47: White

The code is as follows:

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"

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"

Note: all 033 can be changed to E

Example: echo-e "\ 033 [40th 37m black background white character\ 033 [0m"

Echo-e "\ E [40th 37m black background white characters\ E [0m"

The effect is the same.

Word color: 30-39

30: black

31: red

32: green

33: yellow

34: blue

35: purple

36: dark green

37: White

The code is as follows:

Echo-e "\ 033 [47umbent 30m black character on white background\ 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"

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"

ANSI control code

\ 33 [0m turn off all properties

\ 33 [01m set high brightness

\ 33 [04m underline

\ 33 [05m flicker

\ 33 [07m reverse display

\ 33 [08m 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

\ 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

For example:

Let the font turn red and keep flashing

# echo-e "\ 033 [31m\ 033 [05m] Please confirm your operation and enter [YWeiN]\ 033 [0m"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report