0

Many programs are capable to "rewrite" on the same line, not in a STDOUT way.
For example scp write the percentage or many installation programs will show you the nice rotating wheel.

How it works?

3

Assuming that you are talking about console programs, and not progress dialogs in a GUI, the effect of overwriting the last line can be achieved with STDOUT and with just about any console.

Most consoles support the "carriage return" character, which brings the current output position to the beginning of the current line, without otherwise altering what is shown on the console. In most programming languages, this character is represented by the escape sequence \r.
When producing output with carriage return characters in it, the text after a carriage return will overwrite the last line that was written before it.

If you redirect the output the ouput from a program like scp (that produces a progress indication) to a file, then in many cases the file will look similar to this (using the escape sequence for the carriage return character):

 10%\r
 20%\r
 30%\r
 40%\r
 50%\r
 60%\r
 70%\r
 80%\r
 90%\r
100%\r
\n
  • Thanks! I didn't know about it, now I feel noob! :) – Enrichman Sep 12 '15 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.