user1299784
user1299784

Reputation: 2097

How is the fancy command line implemented in Linux?

When installing things in Linux I often see stdout change after printing eg. there might be a counter showing installation progress that starts at 1% and goes up to 100%. How is this done? When I write C programs and I print something using printf, I can't change it afterwards - if I type 1%, it stays that way. How is it done? Is there a different function I have to use?

Upvotes: 0

Views: 172

Answers (1)

SkerryP
SkerryP

Reputation: 76

\r brings you back to the beginning of the line without issuing the \n to go to the next line. Use this to overwrite text on the screen to build progress bars, etc.

See:

How to add a progress bar to a shell script?

Upvotes: 1

Related Questions