I am creating a small console application that requires a progress bar. Something like...
Conversion: 175/348 Seconds |
My question is: how do you delete characters already printed on the console? When I reach the 51st percent, I need to erase this line from the console and insert a new line. In my current solution, this is what happens ...
Conversion: 175/348 Seconds |========== | 50% Conversion: 179/348 Seconds |========== | 52% Conversion: 183/348 Seconds |========== | 54% Conversion: 187/348 Seconds |=========== | 56%
The code I use is ...
print "Conversion: $converted_seconds/$total_time Seconds $progress_bar $converted_percentage%\n";
I do this on Linux using PHP (I will only use the application - so please excuse me for choosing the language). Thus, the solution should work on the Linux platform, but if you have a solution that crosses the platform, that would be preferable.
linux console character erase
Binny VA Jan 10 '09 at 7:42 2009-01-10 07:42
source share