How to change the output color of echo in Linux

后端 未结 29 3471
刺人心
刺人心 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:51

    For readability

    If you want to improve the readability of the code, you can echo the string first then add the color later by using sed:

    echo 'Hello World!' | sed $'s/World/\e[1m&\e[0m/' 
    

提交回复
热议问题