In Linux, shell scripts output color text

Source: Internet
Author: User
Tags echo command

The color of the text terminal can be generated using an ANSI unconventional character sequence. Example:

 

Echo-e "/033 [44; 37; 5 m me/033 [0 m Cool"

 

The preceding command sets the background color to blue, the foreground color to white, the font to flash, the output character "me", and then reset the screen to the default settings, the output character "cool ". "E" is an option for the echo command, which is used to activate the parser for special characters. "/033" leads the sequence of unconventional characters. "M" means setting the attribute and ending the unconventional Character Sequence. In this example, the valid characters are "44; 37; 5" and "0 ". Modify "44; 37; 5" to generate a combination of different colors. The values are irrelevant to the order of encoding.

 

The optional encoding is as follows:

 

Encoding color/Action

 

0. Reset the property to the default setting.

 

1. Set bold

 

2. Set half brightness (simulate color display)

 

4. Set the underline to simulate the color of the color display)

 

5. Set flashing.

 

7. Set reverse Images

 

22. Set the general density

 

24. Close the underline

 

25 turn off flashing

 

27 disable reverse image

 

30 set the black foreground

 

31 set the red foreground

 

32. Set the green foreground

 

33 set the brown foreground

 

34 set the blue foreground

 

35 set purple foreground

 

36 set the blue foreground

 

37 set the white foreground

 

38. Set the underline on the default foreground color

 

39. Disable the underline on the default foreground color

 

40 set a black background

 

41 set the red background

 

42 set a green background

 

43 set brown background

 

44 set the blue background

 

45 set a purple background

 

46 set the blue background

 

47 set the white background

 

49 set the default black background

 

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.