I have a variable "x" , which contains two columns and two row. I wanted to print "hi" in RED color, so I took help of tput
,which printed the result in red. But I also needed to print the columns in proper alignment for that I used column -t
but it is distorting the output. This was due to the fact that some control chars are added by tput.
x="hello $(tput setaf 1)hi $(tput sgr0) whatsup
hey howdy cya"
echo "$x"
hello hi whatsup
hey howdy cya
echo "$x"|column -t
hello hi whatsup
hey howdy cya
I was expecting:
hello hi whatsup
hey howdy cya
Tried to debug ,found that tput is adding some control chars to make "hi" print in red.
echo "$x"|cat -A
hello ^[[31mhi ^[(B^[[m whatsup$
hey howdy cya$
Question:
How to "column -t
" on colored output from tput?
EDIT: Result(ALL IN RED) from @Diego Torres Milano
hello 31mhi Bm whatsup
hey howdy cya