How to change the output color of echo in Linux

后端 未结 29 3586
刺人心
刺人心 2020-11-22 04:28

I am trying to print a text in the terminal using echo command.

I want to print the text in a red color. How can I do that?

29条回答
  •  难免孤独
    2020-11-22 04:47

    echo -e "\033[31m Hello World"
    

    The [31m controls the text color:

    • 30-37 sets foreground color
    • 40-47 sets background color

    A more complete list of color codes can be found here.

    It is good practice to reset the text color back to \033[0m at the end of the string.

提交回复
热议问题