问题
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