Monday, May 13, 2019

console - How does one output bold text in 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.



Answer



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)


then you can use the variables $bold and $normal to format things:



echo "this is ${bold}bold${normal} but this isn't"



gives




this is bold but this isn't



No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...