Copying the GNU screen scrollback buffer to a file (extended hardcopy)

user354134 picture user354134 · Jan 26, 2011 · Viewed 74.2k times · Source

How do I easily copy the GNU Screen scrollback buffer to a file? I.e., a more powerful version of the 'hardcopy' command?

In GNU screen, I can use "Ctrl + A Esc" to enter the scrollback buffer. I could then mark the entire buffer and use "Ctrl + A Ctrl + ]" to paste it into an Emacs buffer, thus saving it to a file.

However, this is tedious. Is there a Screen command that'll simply copy the scrollback buffer to a file, like 'hardcopy' does for the visible portion of the screen?

Answer

Bill picture Bill · Jul 7, 2011

To write the entire contents of the scrollback buffer to a file, type

Ctrl + A and : to get to command mode, then

hardcopy -h <filename>

In older versions of screen, if you just do hardcopy -h, it just writes to the file -h. This was fixed in version 4.2.0, so hardcopy -h writes to hardcopy.N where N is the current window number.