如何在 Bash 中输出粗体文本? [英] How does one output bold text in Bash?
本文介绍了如何在 Bash 中输出粗体文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个在屏幕上打印一些文本的 Bash 脚本:
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.
推荐答案
最兼容的方式是使用 tput
发现正确的序列发送到终端:
The most compatible way of doing this is using tput
to discover the right sequences to send to the terminal:
bold=$(tput bold)
normal=$(tput sgr0)
然后你可以使用变量 $bold
和 $normal
来格式化:
then you can use the variables $bold
and $normal
to format things:
echo "this is ${bold}bold${normal} but this isn't"
给予
这是粗体,但这不是
这篇关于如何在 Bash 中输出粗体文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文