Home » Questions » Computers [ Ask a new question ]

Removing the escape characters from GNU Screen's screenlog.%n

Removing the escape characters from GNU Screen's screenlog.%n

Is it possible to remove the ESC sequences in GNU Screen's output file? Things such as colours, tabs and other escape characters make their way into the log files and become difficult to decipher.

Asked by: Guest | Views: 287
Total answers/comments: 3
Guest [Entry]

"Try this piece of Perl magic:

perl -ne 's/\x1b[[()=][;?0-9]*[0-9A-Za-z]?//g;s/\r//g;s/\007//g;print' < screenlog.0"
Guest [Entry]

"Use ansifilter.

ansifilter screenlog.txt > screenlog.txt.clean"
Guest [Entry]

"If you are screen user then the screen hardcopy solution suggested by Joel
Verks' post will work best -- assuming that you have a large scrollback
defined in your .screenrc:

defscrollback 10000

then you'd do:

Display your screenlog file:

$ cat screenlog.<screen_window_num>

Use hardcopy -h (see screen man page) to save the current window content
and its scrollback buffer into the hardcopy.# file:

<Escape key> (Ctrl-a by default)
:hardcopy -h"