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"

7
  • What OS and shell are you using? Commented Jun 13, 2015 at 1:33
  • The OS is AIX while shell is ksh. Commented Jun 13, 2015 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. Commented Jun 13, 2015 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. Commented Jun 13, 2015 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. Commented Jun 13, 2015 at 12:40

1 Answer 1

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

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.