How to realize Coloring output by Linux
This article mainly introduces Linux how to achieve color output, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Problem description
In the terminal, we often look at the log output (whether it's our own Shell script or running other programs) to see how the program is executing.
However, all terminal logs are the same color (usually the default is white font)
Solution 1. ANSI escape code-the oldest method
Using ANSI escape code is the oldest method:
# echo-e "\ 033 [31 countries 1 countries 4mHello\ 033 [0m" Hello
This command outputs an underlined red Hello string
Method 2. Grc# grc tail-f / var/log/syslog
This command highlights the syslog log output, giving you more control through the configuration file
Thank you for reading this article carefully. I hope the article "how to achieve Linux Color output" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!