Remove BS and ESC from Log files
Solution 1
The output of script
will always contain linefeeds, backspaces and ANSI escape sequences as stated in the manpage. Examples of programs that will correctly display all these are cat
and more
. cat typescript
and more typescript
will display typescripts exactly as it looked when you recorded them.
If you still want to clean the typescripts, take a look at this script. It is a Perl script I stumbled upon some time ago that is made specifically for cleaning up typescripts made with script
.
Try it by running script-declutter myTypescript > cleanTypescript
Edit: Not really related to the answer, but you might be interested in TermRecord. It creates neat, self contained HTML and Javascript representation of your terminal sessions so that anyone can view them without any knowledge of how to handle typescripts. All they need is a web browser.
Solution 2
If you use the -vte
argument to cat
, it will escape the terminal codes.
e.g.
cat -vte myfile
Related videos on Youtube
Bingo
Updated on September 18, 2022Comments
-
Bingo over 1 year
Whenever I use the
script
command to record the keys I type or when I activate the logging mode inscreen
, all BS (Backspace) and ESC (Escape) key presses are also included in the file. e.g:cd ~/foo/tpBSBStmp
.Is there a way to auto remove the BS or the ESC from the file so the final recorded command included in the file would be
cd ~/foo/tmp
?Btw, this also happens in the logging feature of Putty.
I'm open to any scripts that remove the unwanted characters or even another commands that do the same job
-
Bingo almost 10 yearsThanks a lot. I really appreciate the extra info about TermRecord.
-
endolith over 4 yearsI think that's the opposite of what OP wants, but it's what I was looking for, so upvote :D