...making Linux just a little more fun!

2-Cent Tips

2 cent tip: Interpreting color escape sequence

Mulyadi Santosa [mulyadi.santosa at gmail.com]


Thu, 29 Nov 2007 17:02:14 +0700

Suppose you have recorded your console session with "script" command. And then you want to display it via simple "less" command. But wait, you see: (note: by default ls use coloring scheme via command aliasing, so if you don't have it, simply use ls --color)

ESC]0;mulyadi@rumah:/tmp^GESC[?1034h[mulyadi@rumah tmp]$ ls
ESC[00mESC[00;34mgconfd-doelESC[00m ESC[00;34mvirtual-mulyadi.Bx4b1XESC
How do you make these "strange" characters to appear as color? Use less -r <your script file> and you'll see colors as they originally appear.


Talkback: Discuss this article with The Answer Gang

Copyright © 2007, . Released under the Open Publication License unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 145 of Linux Gazette, December 2007

Tux