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 file file
Change the name of the current logfile. The default logfile is gdb.txt.
set logging overwrite [on|off]
By default, GDB will append to the logfile. Set
set logging on to overwrite the logfile instead.
set logging redirect [on|off]
By default, GDB output will go to both the terminal and the logfile.
redirect if you want output to go only to the log file.
set logging debugredirect [on|off]
By default, GDB debug output will go to both the terminal and the logfile.
debugredirect if you want debug output to go only to the log file.
Show the current values of the logging settings.
You can also redirect the output of a GDB command to a shell command. See pipe.