PDA

View Full Version : How do I overwrite a line with bash?


David Marrs
October 20th, 2005, 10:11 AM
Is it possible to output text to the begining of the same line each time, rather than continue from the end of the last character or on a new line? I've got a lot of info to output to the terminal but it would be more useful to me if it just rewrote to the same line rather than overtook the entire terminal window.

JmSchanck
October 20th, 2005, 11:03 PM
Yes you can do this with the escape character "\r"

example:

echo -e "ABCDEF\r123"


output:

123DEF


Same thing in c:

printf("OooOo I wrote some text \r and now I overwrote it\n");

David Marrs
October 21st, 2005, 05:24 AM
thanks :)