Working with terminal controlcodes

Posted in Uncategorized by Julian Kessel - Aug 03, 2011

I wondered about how to clear a line in a shellscript which uses \r to do a carriage return and reuse the same line to output some text:

While the CR does not clear the contents of the line, you have to do that yourself:

  echo -ne "\033[2K\r"`echo $i | awk '{$1=""; print $0}'`

I use that line to display a string in a loop as described above. The \033 is nothing else than the escaped octal notation of \e which is ESC.

You can find a lot more related info to at http://www.termsys.demon.co.uk/vtansi.htm

Tags: COMMENTS

Leave a Reply