Print in color


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Print in color
# 1  
Old 08-24-2006
Data Print in color

I have a short code below:

awk 'NR==1 {printf "'$information'-MYDATA-'$information' \n"} {print $0}' data.file > newdata.file

I want the "information" color in RED and MYDATA in BLUE. How can I do it?

Please help!!!!
# 2  
Old 08-25-2006
If you mean console, try this ANSI color code in your shell:
Code:
# printf 'This word is \x1b[%i;3%imRED!\n\x1b[0m' 1 1

The first 1 is intensity; 0 is dark, 1 is bright. The second 1 is color; 1 is red, 2 is green, 4 is blue, 3 is yellow(red plus green), etc. The '\x1b[%i;3%im' sets color, with the %i's replaced by the 1's. The '\x1b[0m' resets the color back to defaults.
# 3  
Old 08-25-2006
Hi Corona !

Can you please explain me in details of this line as i am unaware of this color all together .
What is that x1b[%i;3%imRED!\n\x1b[om' ??
i am confused
# 4  
Old 08-25-2006
It is an ASCII escape sequence, directly telling the terminal to change colors. The printf substitutes paramaters into it. The "\x1b" part actually becomes one single character, ESC. The "%i" bits get substituted with the integers on the commandline by printf. The rest of it's all literal characters, but the console understands it as a "change color" message.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

2 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. Shell Programming and Scripting

color print using perl

Hi i want to print the text in different color using perl script. i am able to print on console(terminal). but if i try to print the same into a file, i am not able to do color.pl #!/bin/usr/perl use Term::ANSIColor; print "This text is normal.\n"; use Term::ANSIColor qw(:constants);... (3 Replies)
Discussion started by: roopa
3 Replies
Login or Register to Ask a Question