I'm running a program that prints lots of escape characters (like "Esc[1A", to move the cursor up one line), and trying to redirect the output to a log file. When I run the program without redirection, the final output looks something like this:
256 lines processed.
But when I redirect to a log file, this is what the file ends up looking like:
Processing line 1... Esc[1AProcessing line 2... Esc[1AProcessing line 3... ... Esc[1AProcessing line 256... Esc[1A256 lines processed.
What's happening is that on the terminal, the "Esc[1A" character is telling the cursor to back up, so that each successive line overwrites the last line, and in the end, only the last line is displayed.
I want to have the log file appear exactly as the final output of the program would appear without redirection. I know it's possible to pipe the output to
col -bp in order to filter out the escape characters, but I'd like to actually apply them, so that my log files don't end up containing thousands of extraneous lines. How can I achieve this?