color a figure in text file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting color a figure in text file
# 1  
Old 05-01-2009
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
# 2  
Old 05-01-2009
Using ANSI color, to display on your terminal.

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

cheers,
Devaraj Takhellambam
# 3  
Old 05-04-2009
Thanx for your reply.... But it dose not work .. It seems that it copy the strings of the color to the figure ... I have change the threshold from 90 to 20 just for test..
awk '{for(i=1;i<=NF;i++)if ($i >= 20)printf("%s "," \033[31m"$i"\033[0m");else printf("%s ",$i);printf "\n"}' test_mai

Answer:

\033[31m29\033[0m \033[31m38\033[0m 19 \033[31m37\033[0m
\033[31m43\033[0m \033[31m31\033[0m \033[31m32\033[0m 12
\033[31m38\033[0m \033[31m30\033[0m 19 \033[31m35\033[0m
\033[31m26\033[0m \033[31m27\033[0m \033[31m23\033[0m \033[31m21\033[0m
\033[31m22\033[0m \033[31m21\033[0m \033[31m27\033[0m \033[31m24\033[0m
\033[31m26\033[0m \033[31m24\033[0m \033[31m20\033[0m \033[31m24\033[0m
\033[31m28\033[0m \033[31m30\033[0m \033[31m25\033[0m \033[31m21\033[0m
\033[31m25\033[0m \033[31m27\033[0m 18 \033[31m22\033[0m
\033[31m27\033[0m \033[31m30\033[0m \033[31m26\033[0m \033[31m25\033[0m
\033[31m29\033[0m \033[31m30\033[0m \033[31m20\033[0m \033[31m26\033[0m
\033[31m25\033[0m \033[31m24\033[0m \033[31m23\033[0m \033[31m21\033[0m
\033[31m32\033[0m \033[31m31\033[0m \033[31m20\033[0m \033[31m26\033[0m
\033[31m34\033[0m \033[31m29\033[0m \033[31m30\033[0m \033[31m39\033[0m
\033[31m25\033[0m \033[31m20\033[0m 15 12
\033[31m37\033[0m \033[31m30\033[0m \033[31m38\033[0m \033[31m42\033[0m
\033[31m24\033[0m \033[31m26\033[0m 18 18
\033[31m29\033[0m \033[31m23\033[0m \033[31m26\033[0m 17
\033[31m24\033[0m \033[31m28\033[0m 18 \033[31m25\033[0m
# 4  
Old 05-04-2009
Appreciate if i could find an answer to my request..
Thanx n advance
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with change significant figure to normal figure command

Hi, Below is my input file: Long list of significant figure 1.757E-4 7.51E-3 5.634E-5 . . . Desired output file: 0.0001757 0.00751 0.00005634 . . . (10 Replies)
Discussion started by: perl_beginner
10 Replies

2. Shell Programming and Scripting

Color text on shell programming

hello i need the main reference for color code on shell programing i know a few color like: RED='\033 (2 Replies)
Discussion started by: nimafire
2 Replies

3. 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

4. Shell Programming and Scripting

change text color in postscript file

Hi everyone, I have a program that produces postscript files on the fly The color of the files produced are in black and white I want to change the text color of postscript file as the file is being produced without having to manually go into the ps file and change it myself. Any Ideas?... (5 Replies)
Discussion started by: walforum
5 Replies

5. 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

6. 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

7. Shell Programming and Scripting

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... (5 Replies)
Discussion started by: Bluetoot
5 Replies
Login or Register to Ask a Question