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

前端 未结 7 461
隐瞒了意图╮
隐瞒了意图╮ 2020-12-12 08:43

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

相关标签:
7条回答
  • 2020-12-12 08:56

    Ctrl + A, :, and issue the command 'log on'.

    Or set it as the default in your .screenrc file as 'deflog on'.

    0 讨论(0)
  • 2020-12-12 08:58

    Try hardcopy -h to include the whole buffer.

    0 讨论(0)
  • 2020-12-12 08:58

    Do Ctrl + A, H.

    That saves the current screen into a hard copy file, e.g., hardcopy.0 for screen 0. It seems to be a quicker way than going Ctrl + A, : and typing the hardcopy command.

    0 讨论(0)
  • 2020-12-12 09:06

    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.

    0 讨论(0)
  • 2020-12-12 09:06

    Press Ctrl+A :bufferfile /tmp/somefile.txt ENTER, and then Ctrl+A >

    This will write the current contents of the buffer to the named file.

    0 讨论(0)
  • 2020-12-12 09:06

    This worked for me:

    Enter edit mode (~) and type:

    :hardcopy -h buff_file
    

    It created a huge file, of which 98% was empty, but my logs were fully present in remaining 2%.

    0 讨论(0)
提交回复
热议问题