I'm saving standard output stream to a file:
mvn test > output.txt
Before saving to a file I want to properly process ASCII command codes (especially 0x0D and 0x08) in order to make file more readable.
For example, in line 1\rline 2\n the \r should move the position to the start of the same line, so that overwriting from there results in line 2\n being saved. Similarly barbar\rfoo\n should end as foobar\n.
Do such tools exist in Linux or do I have to write something from scratch?
pipe your output through col -b. It doesn't understand all possible control characters and escape sequences, but at least it knows carriage return and backspace. It outputs what would be visible at the end if its input had been printed to a terminal. (An infinitely tall terminal with destructive backspace)
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