putting color on output file script

do you have any simple script on how to change the color and font of a string in a script example

 echo "===================================="
    echo "  sample color script"
    echo "===================================="
    echo "  [1] hello "
    echo "  [2] bye"   

on [1] hello, wanted to use say red bold color. and use different color as well on [2] bye.

hope you could assist.

You want to include Ansi terminal controls in your script, take a look here for details

The portable way is to use tput: Man Page for tput (Linux Section 1) - The UNIX and Linux Forums

tput smso ... bold on
tput rmso ... bold off
tput setf 4 ... switch to red
tput serf 1 ... switch ro blue
tput reset ... reset all (slow)
echo "===================================="
    echo "  sample color script"
    echo "===================================="
    echo "  `tput smso``tput setf 4`[1] hello `tput rmso``tput setf 0`"
    echo "  `tput setf 1`[2] bye`tput setf 0`"
1 Like

see the following examples

 echo -e "\033[33;31m Color Text"

Color Text

 echo -e "\033[33;32m Color Text"

Color Text

echo -e "\033[33;33m Color Text"

Color Text
your looking like this or ..?