我正在编写一个在屏幕上打印一些文本的 Bash 脚本:
echo "Some Text"
我可以格式化文本吗?我想把它加粗。
最佳答案
最兼容的方式是使用 tput
来发现正确的序列发送到终端:
bold=$(tput bold)
normal=$(tput sgr0)
然后你可以使用变量 $bold
和 $normal
来格式化:
echo "this is ${bold}bold${normal} but this isn't"
给予
this is bold but this isn't
https://stackoverflow.com/questions/2924697/