GNU screen: print a detached session to stdout

gnu-screenlogsstdout

I just want to have a quick overview of my detached GNU screen sessions. Is it possible to dump the current content to stdout ? Something like

screen --print SESSION_NAME > file.txt

Best Answer

You can dump one window of a screen session with screen -X hardcopy /some/file, that will save a screen dump of the current window in /some/file.

You can dump a specific window with:

screen -X at 3 hardcopy /some/file

And all of them in a single file with:

screen -X eval 'hardcopy_append on' 'at \\# hardcopy /some/file'

You can also dump one file per window, by specifying which directory to dump them in (if you don't specify it, then they'll be dumped in the directory screen was started in) with

screen -X eval 'hardcopydir /some/dir' 'at \\# hardcopy'

(will be dumped in files called hardcopy.<n>)

See the -h option of hardcopy to include the scroll buffer.

Use screen's -S option as usual to specify the session to run the command in. ⁣   ⁣    ⁣ ⁣

Related Question