Copying GNU screen scrollback buffer to file (extended hardcopy)?

偶尔善良 提交于 2019-11-28 14:57:42
Bill

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.

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.

TL;DR: ^A:writebuf <filename>

OP seems to want a way to use the selected portion of the buffer you get when doing a ^A[ , selecting text using space as the start and finish, then instead of using ^A] to paste, save the resulting selected portion of the buffer to a file.

I know it's years since this has been posted, but I was looking for an answer to the same question, and eventually found:

^A:writebuf <filename>

note: one 'f' in writebuf

Jorge Gutierrez

try hardcopy -h to include the whole buffer

This worked for me: Enter edit mode (~): then type:

:hardcopy -h buff_file

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

ctl-a : the issue command 'log on'

or set it default in your .screenrc as 'deflog on'

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!