keyboard-shortcutsgnu-screen

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


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?


Solution

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

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

    path: location where you want to save the screen log file.

    hardcopy -h <path/filename>
    

    Example:

    hardcopy -h <home/admin/myScreen.log>
    

    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.