I'm trying to write a simple bash function that returns bold text. The code I have written so far is:
function txt_bold() {<br>
echo -e '\033[1m$1\033[0m$2'<br>
tput sgr0<br>
}
When I write txt_bold "This is bold" "And this in plain text"
it returns "$1$2" ($1 in bold). What am I doing wrong here?
Use "
instead of '
.
function txt_bold() {
echo -e "\033[1m$1\033[0m$2"
tput sgr0
}
Within single quotes variables are not getting expanded.
Below's the bottom line of this article, which might help you understand it: What’s the Difference Between Single and Double Quotes in the Bash Shell?