How to change the output color of echo in Linux

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

    red='\e[0;31m'
    NC='\e[0m' # No Color
    echo -e "${red}Hello Stackoverflow${NC}"
    

    This answer correct, except that the call to colors should not be inside the quotes.

    echo -e ${red}"Hello Stackoverflow"${NC}
    

    Should do the trick.

提交回复
热议问题