How to change the output color of echo in Linux

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

    Here is the simplest and readable solution. With bashj (https://sourceforge.net/projects/bashj/), you would simply choose one of these lines:

    #!/usr/bin/bash
    
    W="Hello world!"
    echo $W
    
    R=130
    G=60
    B=190
    
    echo u.colored($R,$G,$B,$W)
    
    echo u.colored(255,127,0,$W)
    echo u.red($W)
    echo u.bold($W)
    echo u.italic($W)
    
    Y=u.yellow($W)
    echo $Y
    echo u.bold($Y)
    

    256x256x256 colors are available if you have the color support in your terminal application.

提交回复
热议问题