ANSI Codes
Changing the Output color of Echo in Linux can be achieved using the respective ANSI escape codes. “00” means echo -n; This is used as an output to the console, but will not work for a specific channel or voice you want to send your data with. In this example, we use 00:1c, which indicates that an important message should be sent directly into our mail server’s outgoing queue. If it didn’t receive any response from us after 20 seconds due to the long delay, then there may be something wrong here. The ANSI for various commonly used colors can be seen below.
The code should be given in the format: R=’\033[0;31m’. This has to be prefixed by an argument called \033[, followed by the code for the color that needs to be specified. Here, 0;31 means Red color.
1. Single Color In the output
Changing the Color of the echo Command’s Output in Linux can be achieved with an additional command: echo -e # or, if you prefer, this line is often used as a placeholder for console output.
Let us try to print the output in green color.
GREEN='\033[0;32m'
echo -e "${GREEN} Green Colored Statement"
Based on this sample command, echo output the input color with green text. To change the color of the output, use one of the escape sequences \ green or $ green. The former changes from red to green.
2. Multi Color In the output
Now, let us try to print a statement in many colors.
For No Color, the escape character is ‘\033[0m’
While changing the output color is straightforward, it can be challenging to choose which color to change it to. For example, if you want green text on white background, you should use $ white instead of $white. On the other hand, if you want blue background on red text, you should instead use $ red. There are many ways to customize your echo output. Using echo allows users to easily modify their computer’s output without requiring additional software or settings tweaks. Changing the text’s color makes it easy for users with visual impairments; this is especially useful when making web pages accessible for those with blindness or low vision.
How to Change the Output Color of Echo in Linux
When working with a computer, some users may encounter a situation where they need to output text in a different color. The colors we are familiar with by now will have been worked out for our particular machine and thus can be replaced easily if needed. Echo is a Linux command that can be used to change the output color of the text. Any text entered using echo is displayed in the new color before being output. The input method for this feature varies: bash, zsh, and python (as well as other shell extensions) will provide option -E, which disables it. There are several ways to change foreground and background colors in Linux. Some examples showing how to use echo are included on this page.