How to echo colored text in linux shell script:

Colored text in Linux shell script:

 

Having a colourful display on shell script is something that’d beautify your experience. Using colour text and echos will help you to highlight and distinguish the shell output on a linux prompt.

Try following command on you bash:

syntax:

echo -e "\033[COLOR1;COLOR2m sample text\033[0m"

The semicolon separated numbers "COLOR1" and "COLOR2" specify a
foreground and a background color.The order of the numbers does not
matter, since the foreground and background numbers fall in non-
overlapping ranges."m" terminates the escape sequence, and the text
begins immediately after that.Although setting the colors separately
also work (i.e. \033[44m\033[32m).


echo -e "\033[33;31m Color Text" - red

echo -e "\033[33;32m Color Text" - green

echo -e "\033[33;33m Color Text" - yellow

echo -e "\033[33;34m Color Text" - blue

echo -e "\033[33;35m Color Text" - Magenta

echo -e "\033[33;30m Color Text" - Gray

echo -e "\033[33;36m Color Text" - Cyan


Enjoy!!!

Comments

Popular posts from this blog

Resolved: DOCKER: Error response from daemon: Could not attach to network / rpc error: code = 7 desc = network not manually attachable.

yum failed 6 times. Cannot continue!

unexpectedly shrunk window (repaired) in dmesg log - TCP Peer