Expanding a little on what wisecracker has already said....
It looks like you are trying to use ANSI terminal escape codes, but they start with an <escape> character; not with the character <3>. Furthermore, you haven't told us what shell you're using and the behavior of echo -e varies considerably from shell to shell, from operating system to operating system, and even if you use the same shell on multiple systems, the behavior of echo -e may vary even when echo is a built-in utility within a given shell.
Using printf avoids the various behaviors of echo and the changes to your color introducing variables can be fixed by replacing the leading 3 with \033 (i.e., the ASCII escape character). In bash you can replace the \033 with \e. In ksh93 you can replace the \033 with either \e or \E. These uses of \e and \E can be used to reference the <escape> character even when you're using those shells on a mainframe that uses EBCDIC instead of an ASCII based codeset. (But you probably won't find terminals that accept ANSI terminal escape codes on a mainframe.)
Note also that it is usually considered to be bad form to write these escape sequences into a file unless the file is associated with a terminal device. For example, on systems where you can tell the ls utility to use various colors to indicate various types of files, it only does that when standard output is directed to a terminal device file. If you redirect the output of ls to a regular file, it won't output the escape sequences to produce those colors.
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Thanks Given: 357
Thanked 462 Times in 383 Posts
Here is an example of hiding a lot of the code (like tput) and allowing a pattern to be specified for conditional high-lighting:
The ansifilter is so that the colors show up here, and would not be needed on a terminal -- I use Konsole, I'm assuming that Mate will be similar.
I'll try to attach the script my-hilite as a text file (in this or a following post) so that you may rename it, modify it, etc.
Best wishes ... cheers, drl
--- Post updated at 10:56 ---
Cannot seem to get attached file to work, so copied here ... cheers, drl
Can anyone help with changing the color of the words in a linux shell script?
I get how to change default background etc in putty, but for some reason the text in the script has different colors for different parts of the cript.
Is there a way to have one color in a linux shell... (5 Replies)
I am using RHEL 6.1 on VMware
I am searching for a way to change background color (not line by line color wich one can using tput command)
basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)