Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I modify a line which I have already echo it to the screen [duplicate]

Tags:

bash

When we download something or install software via Terminal, we always see a number show the progress to us.
The number is changed, but it still in the same line.
How can I do in the bash?

I'm a new basher, help!

like image 596
android_su Avatar asked Jan 23 '26 11:01

android_su


2 Answers

The trick is to use \r instead of \n at the end of the line:

echo -n " 50% complete."$'\r'; sleep 1; echo "100% complete."
like image 180
Burak Arslan Avatar answered Jan 25 '26 08:01

Burak Arslan


Use echo -n.

More informations on this other post.

like image 39
Andrea Avatar answered Jan 25 '26 09:01

Andrea



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!