How to change the output color of echo in Linux

后端 未结 29 3544
刺人心
刺人心 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 05:02

    Use tput with the setaf capability and a parameter of 1.

    echo "$(tput setaf 1)Hello, world$(tput sgr0)"
    

提交回复
热议问题