text color


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting text color
# 1  
Old 05-06-2009
text color

Hi all

I have a file contains columns showing figures as below :

Input file

A B C
D 50 60 90
E 100 20 53
F 30 40 70
G 25 27 45

I want to color the value above or equal 90 by red and to be shown as below
output file
A B C
D 50 60 90
E 100 20 53
F 30 40 70
G 25 27 45

I have used awk command but i fail to get it works

awk '{for(i=2;i<=NF;i++) if ($i >= 90) printf ("%s ","\033[31m"$i"\033[0m");else printf("%s ",$i);printf "\n"}' inputfile

can anybody help me with this...Thanx Smilie
# 2  
Old 05-06-2009
The same working fine for me ..
check any system related settings related to color.
# 3  
Old 05-06-2009
I have got the below output
Note: I have changed 90 by 20 for test only

\033[31m38\033[0m 19 \033[31m37\033[0m
\033[31m31\033[0m \033[31m32\033[0m 12
\033[31m30\033[0m 19 \033[31m35\033[0m
\033[31m27\033[0m \033[31m23\033[0m \033[31m21\033[0m
\033[31m21\033[0m \033[31m27\033[0m \033[31m24\033[0m
\033[31m24\033[0m \033[31m20\033[0m \033[31m24\033[0m
\033[31m30\033[0m \033[31m25\033[0m \033[31m21\033[0m
\033[31m27\033[0m 18 \033[31m22\033[0m
\033[31m30\033[0m \033[31m26\033[0m \033[31m25\033[0m
\033[31m30\033[0m \033[31m20\033[0m \033[31m26\033[0m
\033[31m24\033[0m \033[31m23\033[0m \033[31m21\033[0m
\033[31m31\033[0m \033[31m20\033[0m \033[31m26\033[0m

Any idea...
# 4  
Old 05-06-2009
Thats ANSI color sequence. What terminal do you use to connect to the UNIX BOX? Does it support ANSI..
You may want to use some other terminal to do that - eg putty


cheers,
Devaraj Takhellambam
# 5  
Old 05-06-2009
Dear devaraj
Thanx.. I test the coloring in my terminal & its working but i think the problem is some how with awk option as it prints color string
Instead of showing the color on selected value..

What do you think ?
# 6  
Old 05-11-2009
Thanx everyone for your contrbution..
I tried the command with another server and it works perfect..

Any one has an idea what could be the reason that command not working in my first unix box..
Is there anything that i can check in advance?

Appreciated
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. AIX

How to print color text in AIX?

Hi I'd like to print color text and I've tried this: echo "\033but it didn't woked. When I changed 0 --> 1/4/5, the text "HI" --> bold/underline/blink, but when I changed 31 or 33 to other values, the color didn't change. What's the problem. Need to install something ??? (8 Replies)
Discussion started by: bobochacha29
8 Replies

2. AIX

How to color text and mail

I want to color the text and bold the text and mail these text. input: hi..(in bold) good morning (in blue color) and mail these as in color and bold :wall: (1 Reply)
Discussion started by: AhmedLakadkutta
1 Replies

3. Programming

changing text color in c

I'm writing my own Unix ls command in c and I was wondering if anyone knows how to or can point me to a tutorial that shows me how to change the text color of the filename depending on if it's a directory, regular file, linked file, etc..., like the real ls command does? Thanks. (4 Replies)
Discussion started by: snag49ers
4 Replies

4. Red Hat

New Background and Text Color

Hi. How do I change the background color and text in Fedora. I did find the set_color -b command. Thanks (1 Reply)
Discussion started by: Ccccc
1 Replies

5. Shell Programming and Scripting

color a figure in text file

Good morning, Can someone help to color a figure in columns if its exceeding a threshold using shell script . ex. I have file contains 5 columns showing a value in % I need to show the value in red if it exceed 90 % Appreciate your help (3 Replies)
Discussion started by: Bluetoot
3 Replies

6. UNIX for Dummies Questions & Answers

How to change the font or color of text

Hi Gurus, I have a small requirement where i want to change the color & font of some text in a file. i have a file error.txt which will be created in the script using egrep. After that iam adding these lines at head & tail to that file using the following code awk 'BEGIN{print"Please... (4 Replies)
Discussion started by: pssandeep
4 Replies

7. UNIX for Advanced & Expert Users

Changing Text Color Using VT100

Hi, I want to change the color of the text. Currently, I am using the following VT100 command, which changes the color of the foreground: <ESC>[{attr1};...;{attrn}m The problem is, when I change the color of the foreground, it changes the color of the text as expected, but it also... (4 Replies)
Discussion started by: Abed Alnaif
4 Replies
Login or Register to Ask a Question