The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
color a figure in text file Bluetoot Shell Programming and Scripting 3 05-04-2009 11:25 AM
Changing text color in existing xterm or dtterm fjc UNIX for Advanced & Expert Users 1 03-06-2009 04:07 AM
How to change the font or color of text pssandeep UNIX for Dummies Questions & Answers 4 12-18-2007 06:15 PM
Changing Text Color Using VT100 Abed Alnaif UNIX for Advanced & Expert Users 4 11-27-2006 04:10 PM
how to disable color text in xterm window modemer UNIX for Dummies Questions & Answers 1 06-06-2005 09:20 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-06-2009
Bluetoot Bluetoot is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 7
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
  #2 (permalink)  
Old 05-06-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
The same working fine for me ..
check any system related settings related to color.
  #3 (permalink)  
Old 05-06-2009
Bluetoot Bluetoot is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 7
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 (permalink)  
Old 05-06-2009
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514
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 (permalink)  
Old 05-06-2009
Bluetoot Bluetoot is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 7
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 (permalink)  
Old 05-11-2009
Bluetoot Bluetoot is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 7
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:57 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0