1

I have the line below to echo values with tab between them. The text is also colored, however, some\t does not work.

The output of this one below will have the first two \t not working.

echo "\033[1;31m${var[a]}\t$time\t$end\t$day\t$score\033[m"

This one below will have all the \t working but will also print -e in the screen.

echo -e "\033[1;31m${var[a]}\t$time\t$end\t$day\t$score\033[m"

  • What OS and shell are you using? – G-Man Jun 13 '15 at 1:33
  • The OS is AIX while shell is ksh. – alt123 Jun 13 '15 at 1:37
  • Use printf. You should probably look at its entry in ksh --man or man ksh to learn how to use its format strings, too. – mikeserv Jun 13 '15 at 2:33
  • 1
    @mikeserv; The last AIXes I used had indeed ksh88 installed, but that was in the 1990's. - I've been told (but don't know from own experience) that newer versions of AIX would have [also] ksh93 available. - The official ksh93 is at least freely available, so could be installed if need be. – Janis Jun 13 '15 at 9:57
  • 1
    @mikeserv; Just got that issue confirmed by an AIX using admin: On current AIX'es there's an explicit ksh93 available, and the also available ksh is (for compatibility reasons) a ksh88. - So there should be no issue with availability of ksh's ANSI strings on AIX. – Janis Jun 13 '15 at 12:40
1

Use ksh's ANSI strings feature:

echo $'\033[1;31m${var[a]}\t$time\t$end\t$day\t$score\033[m'

i.e., your string with ANSI escapes embedded in $'...'.

Note: You need a ksh93 (ksh88 does not support that feature).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.