I have a Python CLI program that runs for a long time and has a sort of progressbar, which basically prints some text in the loop without "\n" at the end, at the next iteration it prints "\r" to erase the line, prints some text again and so on:
while some_condition:
print "\rprocessed {} out of {}".format(done_counter, all_counter),
It perfectly works in the console but when I redirect stdout to a file no surprise that I get lot's of "processed ... ... ^M". What I want is to get clean, "rendered" representation of the file as it would be seen in the console, with all that "^M" processed out. I don't want to just remove these control characters but rather apply them to text.
As a workaround currently I do this: tail -n<NUM_LINES> screenlog_file with <NUM_FILES> large enough, then select "rendered" text with mouse, copy that ant paste to new file. I wonder if there is any more convenient way to accomplish that.
EDIT
Owing to @Archemar, found this. It solves my current problem since I can modify the code. However any ideas/workarounds using only linux utils are highly appreciated.