How does one output bold text in Bash?

后端 未结 5 1854
南笙
南笙 2020-12-02 03:55

I\'m writing a Bash script that prints some text to the screen:

echo \"Some Text\"

Can I format the text? I would like to make it bold.

5条回答
  •  没有蜡笔的小新
    2020-12-02 04:20

    In order to apply a style on your string, you can use a command like:

    echo -e '\033[1mYOUR_STRING\033[0m'
    

    Explanation:

    • echo -e - The -e option means that escaped (backslashed) strings will be interpreted
    • \033 - escaped sequence represents beginning/ending of the style
    • lowercase m - indicates the end of the sequence
    • 1 - Bold attribute (see below for more)
    • [0m - resets all attributes, colors, formatting, etc.

    The possible integers are:

    • 0 - Normal Style
    • 1 - Bold
    • 2 - Dim
    • 3 - Italic
    • 4 - Underlined
    • 5 - Blinking
    • 7 - Reverse
    • 8 - Invisible

提交回复
热议问题