bash – How to add a progress bar to a shell script? – Stack Overflow
Posted by jpluimers on 2020/03/17
From [WayBack] bash – How to add a progress bar to a shell script? – Stack Overflow (thanks Mitch Haile!):
You can implement this by overwriting a line. Use
\rto go back to the beginning of the line without writing\nto the terminal.Write
\nwhen you’re done to advance the line.Use
echo -neto:
- not print
\nand- to recognize escape sequences like
\r.Here’s a demo:
echo -ne '##### (33%)\r' sleep 1 echo -ne '############# (66%)\r' sleep 1 echo -ne '####################### (100%)\r' echo -ne '\n'
–jeroen






Leave a comment