How to change the output color of echo in Linux

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

    Here there is a simple script to easily manage the text style in bash shell promt:

    https://github.com/ferromauro/bash-palette

    Import the code using:

    source bash-palette.sh
    

    Use the imported variable in echo command (use the -e option!):

    echo -e ${PALETTE_GREEN}Color Green${PALETTE_RESET}
    

    It is possible to combine more elements:

    echo -e ${PALETTE_GREEN}${PALETTE_BLINK}${PALETTE_RED_U}Green Blinking Text over Red Background${PALETTE_RESET}
    

提交回复
热议问题