BASH Function to Error Warnings and Messages with Terminal Colours

in programming •  2 months ago 

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.



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

My contributions

Delegation Service

Important Update of Delegation Service!

  • Delegate 1000 to justyy: Link
  • Delegate 5000 to justyy: Link
  • Delegate 10000 to justyy: Link

Support me

If you like my work, please:

  1. Delegate SP:
  2. Vote @justyy as Witness:
  3. Set @justyy as Proxy:
    Alternatively, you can vote witness or set proxy here:

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order: