linux - [Solved-6 Answers] How to change the output color of echo in Linux - ubuntu - red hat - debian - linux server - linux pc
Linux - Problem :
How to change the output color of echo in Linux ?
Linux - Solution 1:
Use these ANSI escape codes:
And then use them like this in your script:
Linux - Solution 2:
Use tput with the setaf capability and a parameter of 1.
Linux - Solution 3:
The [31m controls the text color:
30-37 sets foreground color
40-47 sets background color
Linux - Solution 4:
This is the color switch \033[.
Color codes are like 1;32 (Light Green), 0;34 (Blue), 1;34 (Light Blue), etc.
We terminate color sequences with a color switch \033[ and 0m, the no-color code. Just like opening and closing tabs in a markup language.
Simple color echo function solution:
Linux - Solution 5:
A neat way to change color only for one echo is to define such function:
Usage:
Or you could directly use color codes mentioned
Linux - Solution 6:
Use tput to calculate color codes. Avoid using the ANSI escape code (e.g. \E[31;1m for red) because it's less portable. Bash on OS X, for example, does not support it.
Related Searches to - linux - linux tutorial - How to change the output color of echo in Linux
linux red hat debian opensuse ubuntu arch linux mandrake get link linux computer linux pc linux server linux desktop learn linux red hat linux red hat enterprise linux linux software linux tutorial linux operating system suse linux linux download linux os linux ubuntu vmware linux lunix linux windows linux news linux usb linux commands unix linux linux version what is linux linux centos linux ftp linux terminal color codesshell script color outputshell color codesbash printf colorbash ps1 colorstput setaf colorsbash ls colorsbash color scheme