How to get rid of backspace in a log file made the bash program "script"?

340 Views Asked by At

I am logging a program (using the bash utility script) and I get outputs containing backspaces, where it was used, like: "5,^H ^H.6" instead of the final text: "5.6"

if I cat the log file I get the final "5.6", but if direct the result of cat into a file, and I open it with vi I still see "5,^H ^H.6"

Is there a way to save what I actually see using cat (make backspace really delete the character before)?

Many thanks in advance!

1

There are 1 best solutions below

0
user2393987 On

Based on the answer of Ashok I have found the correct hex code for backspace: https://donsnotes.com/tech/charsets/ascii.html

sed 's/.\x08 \x08//g' log.out > log_without_backspaces.out

solved the problem, using just sed as KamilCuk suggested. Many thanks!