How to print color text in AIX?

Hi
I'd like to print color text and I've tried this:

echo "\033[0;31mHI\033[m"

but 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 ???

Hello bobochacha,

I don't have AIX box with me but could you please try as follows and let me know if this helps.

 echo -e "\033[0;31mHI\033[m"
 

We need to add -e option with echo as it will enable interpretation of backslash escapes.

Thanks,
R. Singh

1 Like

Why don't you use printf which behaves consistently across systems (which echo does not do reliably)?

1 Like

Wrong answer. It's AIX, not Linux.

---------- Post updated at 01:12 PM ---------- Previous update was at 01:08 PM ----------

The problem is your terminal. What you want to do, works well on any ANSI-capable terminal. E.g. in my xterm it works. But if you have some dumb terminal, or dtterm (I think - didn't check) this ANSI sequence will not work. If you want to use portable sequences, you have to consult termcap database, what it can provide to you, using infocmp and you can use tput command to make text bold, underline and so on.

1 Like

Thank for your helps. but nothing worked :(:(:frowning:

Yeah, I tried using mobaxterm and it worked :b::b::b:. It seems that securecrt doesn't support this.

Found "xterm" in securecrt, now it's OK. Thanks guy :D:D:D

Hi Bobochacha,

can you please tell me how did you solve this issue with mobaxterm? I have also installed mobaxterm but I dont know how to change the colours of the terminal.

Br,
Neha

I didn't do anything with mobaxterm, just installed and used.
In securecrt, I changed terminal from vt100 --> xterm ( Option / Session Option / Emulation ) and enable the ANSI color option

Hope it helps

Thank you. It is still showing me the file and directory names in black and white colour.
I have no clue how to change the names. May be someone has.

Br,
Neha

NehaJi, I think, you want to see "ls" output in colors. AIX doesn't support colors in the output of ls. You have 2 options:

  1. Write your own ls
  2. Port GNU ls to AIX

Both options are not so difficult and will bring eternal honor to you but only among Linux fans in AIX world.