You may want to save the output of gdb commands to a file. There are several commands to control gdb's logging.
set logging on
set logging off
set logging filefile
set logging overwrite [on|off]
overwriteif you want
set logging onto overwrite the logfile instead.
set logging redirect [on|off]
redirectif you want output to go only to the log file.