You may want to save the output of gdb commands to a file. There are several commands to control gdb's logging.
Enable logging.
Disable logging.
Change the name of the current logfile. The default logfile is gdb.txt.
By default, gdb will append to the logfile. Set overwrite if you want set logging on to overwrite the logfile instead.
By default, gdb output will go to both the terminal and the logfile. Set redirect if you want output to go only to the log file.
Show the current values of the logging settings.