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

故事扮演 提交于 2019-11-27 09:09:33

问题


How do I easily copy the GNU screen scrollback buffer to a file? IE, 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?


回答1:


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.




回答2:


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.




回答3:


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




回答4:


try hardcopy -h to include the whole buffer




回答5:


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 %




回答6:


ctl-a : the issue command 'log on'

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




回答7:


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.



来源:https://stackoverflow.com/questions/4807474/copying-gnu-screen-scrollback-buffer-to-file-extended-hardcopy

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