I have a command that creates very verbose output, on the order of hundreds of lines per second. However, the command uses \r
to overwrite the previous line of output, in a manner similar to a progress bar. Occasionally it writes a newline to the terminal, which "bakes" the current output line.
When redirecting this output to a file, I get hundreds of megs of output - each line is written to the file, instead of being 'overwritten' when the carriage return occurs.
I understand this is the expected behavior, and that one way to solve it would be to make the program smarter, and realize it's being redirected to the file and not print this interactive status. However, I can't modify this program.
Is there some way I can pipe/filter this output so that what ends up in the final output file is the same as what I would see if I ran it interactively on the terminal?
I've tried:
spammy_cr_command | uniq
... which outputs the same as without uniq
and also:
spammy_cr_command | sed '/\r/d'
... which deletes the "baked" lines that contain the newline character as well.