Coloring Style Text Using Shell Scripting Color Codes

Using coloring Style Text using Shell Scripting, You can Make your shell scripting out more interesting and attractive. Like error’s warnings on shell scripting will be shown with different colors to grab users attention.

Colored Text

echo -e '3[34;42mColorFull Message3[0m'
Coloring Style Using Shell Scripting

Colored Text Output

Coloring Style Text Using Shell Scripting – Color Codes Table

Color Background Foreground
Red 41 31
Black 40 30
Green 42 32
Blue 44 34
Yellow 43 33
Magenta 45 35
Cyan 46 36
white 47 37

Let’s see some color combination examples

Multiple Colors

Multiple Colors

Changing text Style in shell script

Style Number
Plain 0
Bold 1
Low Intensity 2
Underline 4
Blinking 5
Reverse 7
Invisible 8
[user@rhel7 ~]$ cat color.sh
#!/bin/bash
## Colors in Bash programming
echo -e "3[5;31;40mhttps://arkit.co.in3[0m"

Using above color code in shell script. Text will blink continuously background is black color and text in red color. you can also format your text coloring by assigning the color code to variables like shown below.

#/bin/bash
## Coloring style Text shell script
COLOR="3[4;34;37m"
NONE="3[0m"
echo -e $COLOR"Message Or Command Output"$NONE

You can use multiple combination from above mentioned table while writing shell scripts.

Related Articles

Bash If Statement Make Decisions

Introduction to Linux Shell Script Course

Bash Scripting Video tutorial for Beginners

Monitor CPU Utilization Using Shell Script

Complete Shell Programming Video Tutorial

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published. Required fields are marked *