We sometimes need in BASH script to display messages with different format/colour to terminal console. For example, the warnings messages are blue, and error messages are red. We can use the following customize echo functions to display messages of different types. The colours are defined and easily customizable.
#!/bin/bash
terminalColorClear='\033[0m'
terminalColorEmphasis='\033[1;32m'
terminalColorError='\033[1;31m'
terminalColorMessage='\033[1;33m'
terminalColorWarning='\033[1;34m'
echoDefault() {
echo -e "${terminalColorClear}$1${terminalColorClear}"
}
echoMessage() {
echo -e "${terminalColorMessage}$1${terminalColorClear}"
}
echoWarning() {
echo -e "${terminalColorWarning}$1${terminalColorClear}"
}
echoError() {
echo -e "${terminalColorError}$1${terminalColorClear}"
}
echoError "echoError"
echoWarning "echoWarning"
echoMessage "echoMessage"
echoDefault "echoDefault"
This will show different messages to console:
--EOF (The Ultimate Computing & Technology Blog) --
Reposted to Blog
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Thank you for reading ^^^^^^^^^^^^^^^
NEW! Following my Trail (Upvote or/and Downvote)
Follow me for topics of Algorithms, Blockchain and Cloud.
I am @justyy - a Steem Witness
https://steemyy.com
My contributions
- Video Downloader
- Steem Blockchain Tools
- Free Cryptos API
- VPS Database
- Computing Technology Blog
- A few useless tools
- And some other online software/tools
- Merge Files/Videos
- LOGO Turtle Programming Chrome Extension
- Teaching Kids Programming - Youtube Channel and All Contents
Delegation Service
Important Update of Delegation Service!
Support me
If you like my work, please:
- Buy Me a Coffee, Thanks!
- Become my Sponsor, Thanks!
- Voting for me:
https://steemit.com/~witnesses type in justyy and click VOTE
- Delegate SP: https://steemyy.com/sp-delegate-form/?delegatee=justyy
- Vote @justyy as Witness: https://steemyy.com/witness-voting/?witness=justyy&action=approve
- Set @justyy as Proxy: https://steemyy.com/witness-voting/?witness=justyy&action=proxy
Alternatively, you can vote witness or set proxy here: https://steemit.com/~witnesses
@justyy I didn't get upvote on my latest post.
https://steemit.com/hive-144064/@blacks/village-woman-utilizes-her-time-for-the-betterment-of-her-family
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit