A command file for the debugger is a file of lines that are the debugger commands. Comments (lines starting with #) may also be included. An empty line in a command file does nothing; it does not mean to repeat the last command, as it would from the terminal.
When you start the debugger, it automatically executes commands from its init files. These are files named .gdbinit. The debugger reads the init file (if any) in your home directory, then processes command line options and operands, and then reads the init file (if any) in the current working directory. This is so the init file in your home directory can set options (such as set complaints) which affect the processing of the command line options and operands. The init files are not executed if you use the -nx option; see Section 14.1.2.
You can also request the execution of a command file with the source command:
Execute the command file filename.
The lines in a command file are executed sequentially. They are not printed as they are executed. An error in any command terminates execution of the command file.
Commands that would ask for confirmation if used interactively proceed without asking when used in a command file. Many debugger commands that normally print messages to say what they are doing omit the messages when called from command files.