Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize Coloring output by Linux

Shulou Source: shulou.com Published: 2022-06-03 07:14:29 10月02日 Update

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!

Tags: Output method article color log antiquity command more program terminal same underline value interest at the same time font character string case file Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MariaDB NVidia macOS OPPO Reno