I have a little Perl script (On Windows) that checks some files for me as an aid to my day-to-day business. At the moment it prints out something like...
0%
25%
50%
75%
Complete
But I can remember scripts I've used in the past that didn't print progress on a line-by-line basis, but which updated the output on the display, presumably by moving the cursor back and over-printing what was there.
Anyone know what magic is required? Portability isn't important to me, the script is quite disposable.
You could use curses and make a nice progress bar.
EDIT: Or do something like this:
print "##### [ 10%]\r";
# Do something
print "########## [ 20%]\r";
# Do something else
print "############### [ 30%]\r";
# Do some more
# ...
# ...
# ...
print "##################################### [100%]\n";
print "Done.\n";
In addition to the other answers, \r will go back to the beginning of the current line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With